Logo

Programming-Idioms

History of Idiom 98 > diff from v13 to v14

Edit summary for version 14 by programming-idioms.org:
[Go] ts has type int64.

Version 13

2016-04-17, 21:20:55

Version 14

2016-12-06, 12:39:06

Idiom #98 Epoch seconds to date object

Convert a timestamp ts (number of seconds in epoch-time) to a date with time d. E.g. 0 -> 1970-01-01 00:00:00

Idiom #98 Epoch seconds to date object

Convert a timestamp ts (number of seconds in epoch-time) to a date with time d. E.g. 0 -> 1970-01-01 00:00:00

Imports
import "time"
Imports
import "time"
Code
d := time.Unix(ts, 0)
Code
d := time.Unix(ts, 0)
Comments bubble
The second argument is nanoseconds.
Comments bubble
ts has type int64.
The second argument is nanoseconds.
Doc URL
https://golang.org/pkg/time/#Unix
Doc URL
https://golang.org/pkg/time/#Unix
Demo URL
http://play.golang.org/p/dgeDwQieaU
Demo URL
http://play.golang.org/p/dgeDwQieaU