|
|
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) |
2020-10-21 16:54:31.842940388 +0000 UTC m=+0.000067188
1603299271
1603299271842
|
fmt.Println(nanos) |
2020-10-21 16:54:32.304220566 +0000 UTC m=+0.000102698
1603299272
1603299272304
1603299272304220566
|
|
|
fmt.Println(time.Unix(secs, 0)) |
2020-10-21 16:54:34.06693101 +0000 UTC m=+0.000051144
1603299274
1603299274066
1603299274066931010
2020-10-21 16:54:34 +0000 UTC
|
fmt.Println(time.Unix(0, nanos)) |
2020-10-21 16:54:34.438204406 +0000 UTC m=+0.000072338
1603299274438
1603299274438204406
2020-10-21 16:54:34.438204406 +0000 UTC
|
} |
2020-10-21 16:54:34.776561116 +0000 UTC m=+0.000108196
1603299274776
1603299274776561116
2020-10-21 16:54:34.776561116 +0000 UTC
|