I’ve been playing around with the Bing API using json and PHP. The array spits out the following for dates:
[end] => /Date(1354867200000)/
[lastModified] => /Date(1349441488000)/
I thought this was a unix timestamp, but it I don’t think it is. What I did was a preg_replace like this
$last_updated = $resource->lastModified;
$last_updated_timestamp = preg_replace('/[^0-9.]*/','',$last_updated);
Then tried to convert it to a date
$last_updated_date = date('l F d Y g:i:s A',$last_updated_timestamp);
The results that it’s showing me for date range back from the year 1967 to 2000. Is this a different kind of timestamp that I don’t know of? If so, how do I correct this? Any help would be appreciated!
The number part is milliseconds-since-the-Epoch (January 1, 1970 at midnight — the milliseconds version of a unix timestamp). This is a fairly conventional way to represent dates in JSON (since JSON doesn’t have a date type).
So
getdate(theNumber / 1000)will give you the date (sincegetdateexpects seconds, not milliseconds, since The Epoch).