O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

The Time function implements the interfaces for Binary, Gob, and JSON serialization. The JSON format is considered to be very universal, so an example on how the value is serialized to JSON is shown. Note that the Time function serializes the value in the manner of RFC 3339 (https://www.ietf.org/rfc/rfc3339.txt), which proposes a so-called internet date/time format. 

Another very universal way to serialize/keep the time is to use the epoch time. The epoch time is independent of timezones because it is defined by seconds/nanoseconds elapsed since an absolute point in time. Finally, it is represented as a number so there is no reason to serialize and deserialize the value.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required