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 : ...