DEV Community

Discussion on: Do you prefer unix epoch (a number) or ISO 8601 (a string) for timestamps?

Collapse
 
ben profile image
Ben Halpern

I sort of feel like we're wrong either way. Even epoch is kind of frustrating because of how it's either given as seconds or milliseconds as a default depending on the environment and there's always an overhead of making sure you're doing it right.

An API that delivered the value in a couple ways and was super explicit about it seems like something that's good to work with—even if the client could translate between them.

Collapse
 
xngwng profile image
Xing Wang

yeah, the problem is that there is no standard way.

Stripe APIs use epoch.
Twitter and Dropbox APIs use ISO 8601.

So just curious what about people's preferences.

Collapse
 
rhymes profile image
rhymes

I wouldn't be surprised if Stripe chose unix epochs because they interact with third party bank or credit card systems and that makes their lives easier or because they store payment events in a time series DB and their DB uses unix timestamps. Maybe after validating the payload, they ship it to some queue and that gets written as is to a DB.

Or maybe they just chose by tossing a coin :D