Reputation: 115
When I give the timestamp argument to php date() the incorrect date is returned. Formatting is correct, however the result is not as expected.
src is from Hubspot json.
public 'publish_date' => int 1438079400000
$feed = (object) $this->json;
$string = '';
if( $feed->total_count > 0):
foreach( $feed->objects as $item ):
$item = (object) $item;
date_default_timezone_set('Europe/London');
ob_start();
?>
<?php echo date( 'l jS F Y', $item->publish_date ); ?>
<?php
$string .= ob_get_clean();
endforeach;
endif;
return $string;
Results in Sunday 14th April 47546
Epoch Converter check says timestamp is Thu, 30 Jul 2015 09:30:00 GMT
Using date() without the timestamp returns the correct date for today.
Upvotes: 1
Views: 719
Reputation: 3337
You need to divide the date by 1000.
1438079400000 -> 14380794000
php > echo date('Y-m-d H:i:s', 1438079400000);
47540-12-03 12:00:00
php > echo date('Y-m-d H:i:s', 1438079400);
2015-07-28 11:30:00
Upvotes: 2