Start a personal dev blog on your domain for free with Hashnode and grow your readership.
Do you prefer to use Unix Epoch or ISO 8601 format for timestamps?
Unix Epoch
53%
ISO 8601
47%
Another format
0%
43 votes · Closed
Especially in API interfaces, where JSON don't have timestamps type natively. You'll have to represent the timestamp as either a string or a number. Do you prefer to use IOS 8601 (a string) or Unix Epoch (a number), or some other format?
After the poll, can you comment on:
- to what precision?
- why you prefer one over the other?
Sébastien Portebois
Software architect at Ubisoft
Mar 2, 2019
We had that discussion a few time with the team, and we always came back to the same conclusion:
And regarding epoch format (seconds, versus milliseconds), is usually depends on the data itself. When it’s to keep track of human-based interaction (user A did Foo on Bar at this timestamp), using second is perfectly fine. When the goal is to record device activity (we’re an IoT company with a lot of data streams), usually milliseconds is required (when you have a device send 20 values each seconds, it’s just common sense ;-)
As a rule of thumb, I’d say the goal is always to make it as efficient and error-free as possible. (Hence the choice of ISO for the API: as humans write code to call our API, ISO is self-documented and removes all the questions, assumptions, and therefore risks os misuse)
Mark
Mar 2, 2019
Advantages of timestamp:
Advantages of iso or other readable format:
So I guess it depends: if performance is important I'd favor timestamps, while if humans often read it I'd favor text. (Of course some debuggers will always read it, but more often than not they don't need to know which exact day it represents).
Chris Rosillo
Full Stack Dev @ Attractions.io
Mar 2, 2019
ISO 8601 - purely because, as a human, I can know what date/time it is by eye vs. having to stick it in a unix timestamp converter.