Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unix time stamp or string with time zone?

I my web REST API service I've decided to return a dateTime data as a string with a timezone which looks like this: "someDate":"2012-01-23T22:52:37.039+02:00" I wonder, how idiomatic is it? If I returned it as Unix time stamp, would it be more sensible?

like image 744
Incerteza Avatar asked Dec 12 '25 23:12

Incerteza


1 Answers

Personally, I prefer using unix timestamps in situations like this because it is completely timezone agnostic and leaves the timezone interpretation entirely up to the client. Additionally, depending on your client, it's generally less code to parse a unix timestamp into a date than a date string, but that's likely only an ancillary consideration.

like image 142
djmorton Avatar answered Dec 15 '25 12:12

djmorton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!