Reputation: 789
I got the following format of date from an API:
1468102548
I'm trying to convert this date to a normal human readable format, however I can't get it to work.
Here's what I've tried so far:
$creation_date = "1468102548";
$input1 = $creation_date / 1000;
$newDate_creation_date = date("Y-m-d", $input1); // Output: 1970-01-17 (It's not right)
Upvotes: 1
Views: 2029
Reputation: 219824
That timestamp is not in milliseconds so dividing it by 1000 is skewing your date.
$creation_date = new DateTime('@1468102548');
echo $creation_date->format('Y-m-d'); // Outputs 2016-07-09
Upvotes: 4