Reputation: 2194
What's the standard (or some kind of iso-conform thing) format to display date (year, month, day) and time (Hours minutes and seconds) together as an result of an API Request? Or should a timestamp be returned in this case?
Upvotes: 2
Views: 4361
Reputation: 57670
Use ISO8601 format. And use UTC timezone always. Its the standard by ISO and should be parsable by any library.
Example 2012-02-28T20:27:21+0000
In php use DateTimeZone and DateTime object combindly to get an ISO8601 date.
$dt = new DateTime("now", new DateTimeZone("UTC"));
echo $dt->format(DATE_ISO8601)`
See Date/Time in PHP manual to know more.
Upvotes: 7
Reputation: 48505
RFC822 Format: 18 Feb 2012 14:27:18 -0000
DAY MONTH YEAR HOUR:MINUTES:SECONDS UTC-OFFSET
Using date():
date('d M y H:i:s O')
Twitter's API uses it, And some of its benefits are that it's readable by humans and easy to parse in PHP, JavaScript, And other languages. And you know which timezone the date is presented in.
Upvotes: 0
Reputation: 10346
I think returning timestamp
would be a better idea.
It allows your API users to manipulate it easily.
(My opinion)
Upvotes: 2