Logo

Programming-Idioms

History of Idiom 98 > diff from v8 to v9

Edit summary for version 9 by :
[Go] +DemoURL

Version 8

2016-01-01, 00:50:49

Version 9

2016-01-01, 01:44:27

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
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