epoch _ golang
A common requirement in programs is getting the number of seconds, millisecond, or nanoseconds since Unix epoch. Here's how to do it in Go
package main import ( "fmt" "time" ) func main() { now := time.Now() secs := now.Unix() nanos := now.UnixNano() fmt.Println(now) millis := nanos / 1000000 fmt.Println(secs) fmt.Println(millis) fmt.Println(nanos) fmt.Println(time.Unix(secs, 0)) fmt.Println(time.Unix(0, nanos)) }
1427346457 1427346457254 1427346457254439916 2015-03-26 13:07:37 +0800 CST 2015-03-26 13:07:37.254439916 +0800 CST
总结 :
1 : ...
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。