1

i am trying to get date from a timestamp which is coming from an api ,but it will shows the wrong date.

<?php 
//its from the api also its timestamp of the today 
$timestamp="1460364355000";
 //  but it will shows the wrong date.
echo date('Y/m/d',$timestamp);

?>

When i check the above timestamp this website it will shows the correct date ,but using php i will get the wrong date.

Blessan Kurien
  • 1,645
  • 9
  • 31
  • 63

1 Answers1

1

You need to divide the timestamp by 1000, this is to remove milliseconds from the timestamp.

<?php
    $timestamp=1460364355000/1000;
    echo date('Y/m/d',$timestamp);
?>
Panda
  • 6,955
  • 6
  • 40
  • 55