原创文章,转载请注明出处
https://qiedd.com/
将13位的时间戳毫秒转为带小数点的时间格式
package main import ( "fmt" "time" ) func main() { var i int64 = 1666666666666 layout := "2006-01-02 15:04:05.000" t := time.Unix(0, i*int64(time.Millisecond)) fmt.Println(t.Format(layout)) }
同理,也能转换微秒、纳秒
package main import ( "fmt" "time" ) func main() { var i int64 = 1666666666666666 layout := "2006-01-02 15:04:05.000000" t := time.Unix(0, i*int64(time.Microsecond)) fmt.Println(t.Format(layout)) }
0 条评论