update epoch
This commit is contained in:
parent
3d50c64ebd
commit
7402ad51a6
@ -16,12 +16,18 @@ func main() {
|
||||
now := time.Now()
|
||||
secs := now.Unix()
|
||||
nanos := now.UnixNano()
|
||||
fmt.Println(now)
|
||||
|
||||
// Note that there is no `UnixMillis`, so to get the
|
||||
// milliseconds since epoch you'll need to manually
|
||||
// dive from nanoseconds.
|
||||
millis := nanos / 1000000
|
||||
fmt.Println("secs: ", secs)
|
||||
fmt.Println("millis:", millis)
|
||||
fmt.Println("nanos: ", nanos)
|
||||
fmt.Println(secs)
|
||||
fmt.Println(millis)
|
||||
fmt.Println(nanos)
|
||||
|
||||
// You can also convert integer seconds or nanoseconds
|
||||
// since the epoch into the corresponding `time`.
|
||||
fmt.Println(time.Unix(secs, 0))
|
||||
fmt.Println(time.Unix(0, nanos))
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
$ go run epoch.go
|
||||
Secs: 1348240948
|
||||
Millis: 1348240948517
|
||||
Nanos: 1348240948517870000
|
||||
$ 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user