update epoch
This commit is contained in:
parent
3d50c64ebd
commit
7402ad51a6
@ -16,12 +16,18 @@ func main() {
|
|||||||
now := time.Now()
|
now := time.Now()
|
||||||
secs := now.Unix()
|
secs := now.Unix()
|
||||||
nanos := now.UnixNano()
|
nanos := now.UnixNano()
|
||||||
|
fmt.Println(now)
|
||||||
|
|
||||||
// Note that there is no `UnixMillis`, so to get the
|
// Note that there is no `UnixMillis`, so to get the
|
||||||
// milliseconds since epoch you'll need to manually
|
// milliseconds since epoch you'll need to manually
|
||||||
// dive from nanoseconds.
|
// dive from nanoseconds.
|
||||||
millis := nanos / 1000000
|
millis := nanos / 1000000
|
||||||
fmt.Println("secs: ", secs)
|
fmt.Println(secs)
|
||||||
fmt.Println("millis:", millis)
|
fmt.Println(millis)
|
||||||
fmt.Println("nanos: ", nanos)
|
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
|
$ go run epoch.go
|
||||||
Secs: 1348240948
|
2012-10-31 16:13:58.292387 +0000 UTC
|
||||||
Millis: 1348240948517
|
1351700038
|
||||||
Nanos: 1348240948517870000
|
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