What is the best practice for sharing dates in an API?
Is it best to share dates with an SQL-like datetime format – ‘YYY-MM-DD HH:MM:SS’ with an optional timezone embedded inside of it?
Or is it best to use milliseconds based on UTC?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I prefer to encode times as full ISO 8601 dates, but with the constraint that my code only ever generates them in the UTC timezone. If you’ve got a good date parsing library (e.g., Jodatime for Java) accepting full ISO 8601 is not particularly difficult and they’re at least somewhat readable. (Offsets from some epochal instant are nothing like as easy for people to read.)