Because JSON doesn't support a standard date format I'm going to have to serialise/deserialise to _something_. A quick google has found me numerous different approaches - anyone care to point me at a specific best practice
( Read more... )
Otherwise, the ISO format, which does. (2014-02-01T08:04:00)
If your language has serialization of its own, then you could use that and just give JSON the string (as you could in PHP, if you had DateTime objects).
The downside with unix timestamp is that it's a PITA for humans to read.
I have lost count of the number of times I've had to type FROM_UNIX() or whatever the SQL function is to make my database queries produce something I can actually understand when debugging.
But on the other hand, I'm converting it into a JS Date at the point where it's being read into the UI. So I'm never actually having to deal with a timestamp by eye - I'm either seeing it in the Java debugger as a DateTime object, or in the JS debugger as a Date object.
If I was writing it for something other people would use from different front ends then yeah, readability would definitely be a factor.
Ok, you talked me into it. It was a two line change to move it over to the readable version, and the JS side still works perfectly. So I've done that :->
Otherwise, the ISO format, which does. (2014-02-01T08:04:00)
If your language has serialization of its own, then you could use that and just give JSON the string (as you could in PHP, if you had DateTime objects).
Reply
My two languages are Java (which can easily convert to/from Epoch) and Javascript (ditto).
Reply
I have lost count of the number of times I've had to type FROM_UNIX() or whatever the SQL function is to make my database queries produce something I can actually understand when debugging.
Reply
But on the other hand, I'm converting it into a JS Date at the point where it's being read into the UI. So I'm never actually having to deal with a timestamp by eye - I'm either seeing it in the Java debugger as a DateTime object, or in the JS debugger as a Date object.
If I was writing it for something other people would use from different front ends then yeah, readability would definitely be a factor.
Reply
Reply
Leave a comment