fnev.eu fnev.eu - 1 year ago 55
reST (reStructuredText) Question

Which date and time format is most interesting to return with an API

With our API, we want to send some informations about our objects, like publication date and time. Which format do you recommend to return, to ensure easy use, with different programming languages (PHP, Ruby, JavaScript, ...) ?

I thought of 2 responses:

"published": "2016-06-30T14:45:16+0200", //ISO 8601


"published": 1467290716, //Timestamp

Thanks in advance !

Answer Source

In my experience, instead of deciding the format according to the language, I would decide according to the usage.

If it were only a matter of the language, I would stick to the timestamps, just be careful as what length of timestamp you use (Regular 32 bit format will stop working in january 2038 because of overflow, so perhaps you might need a 64 bit long timestamp)

But if you're using the date only as a human readable information, there's no need of converting from timestamp to text, so I would choose the text option.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download