php – What is this time format? – Education Career Blog

I am being returned this time format from an API:

1287498792000

Can anyone advise what format that is and how I would parse it in PHP?

,

This format is the Number of milliseconds since 1970-01-01.

Your date represents 2010-10-19 @ 14h33 if i’m not mistaken.

Just divide it by 1000 and use the standard php functions for unix timestamps like date to display it or getdate to extract the different parts.

,

It’s a Unix timestamp represented in milliseconds — equivalent to the return value from time() multiplied by 1,000 (timestamp in PHP are in seconds, not milliseconds).

You can use it directly1 in PHP, e.g. for the date() function:

print date('l jS \of F Y h:i:s A', 1287498792000 / 1000);
// Outputs: Tuesday 19th of October 2010 02:33:12 PM

EDIT
1 Yes, it seems to be in milliseconds. Divide by 1,000 in order to get a timestamp that PHP understands.

,

It’s a UNIX timestamp – it represents the count of seconds since January 1st, 1970.
You can use PHP’s date() function to convert it to a human readable format.

Leave a Comment