Interesting question came up at work in regards to the better format of passing a date/datetime as a url parameter in an API: Is it better to pass as a unix timestamp, or as a plaintext date string (01/30/2015 04:17:57pm, 2015-01-27T16:17:57+00:00)?

closed as primarily opinion-based by GlenH7, Doval, user40980, gnat, Bart van Ingen Schenau Feb 2 '15 at 16:19

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    "What are the pros and cons" generally isn't a good question. – Doval Jan 30 '15 at 17:28
  • @Doval reworded – jsanc623 Jan 30 '15 at 17:35
  • 2
    You've changed the wording, but not the question. What is your definition of "better"? – Doval Jan 30 '15 at 17:41
  • Better = which format is more portable, which format is more widely used, which format is more widely accepted / acceptable, etc. Should I change the question entirely rather than rewording it to make it less broad? – jsanc623 Jan 30 '15 at 17:54

It depends on the usage, but I'd probably say it's safest to convert to UTC then pass the ISO 8601 style string as you suggest.

That way, it's human-readable, and you don't have to worry about different time zones, etc.

While I was researching for an answer, I found an interesting answer on StackOverflow you might want to read: link.

(edit) Also, if you're using ISO 8601, there's no doubt about the interpretation of the format (DD/MM/YYYY vs. MM/DD/YYYY vs. YYYY/DD/MM vs. YYYY/MM/DD etc.).

  • 2
    Just as an addendum to this answer, UNIX timestamps are limited in the epoch they can denote, they don't handle dates prior to 1970 very well. So an text string makes sense if you need to handle a very wide range of dates and times. – Jim Nutt Jan 31 '15 at 1:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.