Go 有一個time.Unix將秒轉換為日期時間的函式。
Unix returns the local Time corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970 UTC.
有沒有可以從1904轉換秒的功能?
基本上需要將從 1904 年開始的秒數轉換3400769156為日期時間。
uj5u.com熱心網友回復:
沒有現有的功能,但自己創建一個并不難:
func since1904ToTime(sec int64) time.Time {
return time.Date(1904, time.January, 1, 0, 0, 0, 0, time.Local).Add(time.Second*time.Duration(sec))
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/463407.html
