3 ms·
When are UNIX time or ISO-8601 insufficient?
by jvoorhis 15y ago
When are UNIX time or ISO-8601 insufficient?
- billpg 15y ago"dtSomeTimestamp": "2011-08-24T18:02:00.000Z" Is that a date and time, or a string that just happens to look like a date and time? JSON doesn't know the answer, so a convention outside of JSON will need to decide.
- skrebbel 15y agoBecause every programming language's library does it slightly different. With the T, without the T, with or without the Z, converted to UTC or not.. Of course it's no rocket science to figure out, but it's work every time. Notably, JavaScript has no standard way to convert a Date to e.g. 2007-03-01T13:00:00Z. UNIX timestamps are worse because there's no hint about the timezone (should be UTC but often isn't), plus no space for milliseconds. Of course you can just *1000 for msecs and document that it's UTC, but once again, not trivial. Basically, you can't just convert a JSON string date into your language's Date(Time) class and be sure that it went right. This is a lot of energy wasted.