Logo

Programming-Idioms

History of Idiom 98 > diff from v11 to v12

Edit summary for version 12 by :
New Java implementation by user [encapsulator]

Version 11

2016-02-17, 07:27:09

Version 12

2016-02-18, 16:58:02

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
Demo URL
http://play.golang.org/p/dgeDwQieaU