4 ms·
JSON in ECMAScript 5 does have a date/time type. A specific ISO 8601 subset: > JSON.stringify(new Date()) "2014-03-02T15:08:55.309Z"
by TazeTSchnitzel 13y ago
JSON in ECMAScript 5 does have a date/time type. A specific ISO 8601 subset:
> JSON.stringify(new Date())
"2014-03-02T15:08:55.309Z"
- petilon 13y agoClose. That's a string that can be parsed as a date as opposed to a date literal.
- ollysb 13y ago> JSON.parse("{\"date\":\"2014-03-02T16:08:43.444Z\"}") Object {date: "2014-03-02T16:08:43.444Z"}
- TazeTSchnitzel 13y agoYes, but it is trivial to then convert it to a date with the new Date() constructor.
- byroot 13y agoBut it's not trivial to know that it's a date. It's ok if you are expecting a Date. But when you want to write generic code that "discover" the properties, then you have to do dirty things, like trying to parse every single strings as a date.