【问题标题】:Getting date from timestamp: wrong date in php [duplicate]从时间戳获取日期:php中的错误日期[重复]
【发布时间】:2016-08-01 09:47:42
【问题描述】:

我正在尝试从来自 api 的时间戳中获取日期,但它会显示错误的日期。

<?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);

?>

当我检查上面的时间戳this website 时,它会显示正确的日期,但使用 php 我会得到错误的日期。

【问题讨论】:

    标签: php date


    【解决方案1】:

    您需要将时间戳除以 1000,这是从时间戳中删除毫秒。

    <?php
        $timestamp=1460364355000/1000;
        echo date('Y/m/d',$timestamp);
    ?>
    

    【讨论】:

    • 是的,它解决了我的问题
    • @BlessanKurien 不客气 :)
    • 需要等待6分钟才能接受答案
    猜你喜欢
    • 2023-03-22
    • 2018-10-05
    • 1970-01-01
    • 2013-05-28
    • 1970-01-01
    • 1970-01-01
    • 2016-11-09
    • 1970-01-01
    相关资源
    最近更新 更多