Go实例: Epoch

Emma ·
更新时间:2024-11-13
· 285 次阅读

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)) }$ go run epoch.go 2012-10-31 16:13:58.292387 +0000 UTC 1351700038 1351700038292 1351700038292387000 2012-10-31 16:13:58 +0000 UTC 2012-10-31 16:13:58.292387 +0000 UTC



GO实例 GO

需要 登录 后方可回复, 如果你还没有账号请 注册新账号