douxi3404 2015-01-12 08:50
浏览 41
已采纳

显示具有不同时区的多个日期时间

is it possible in php to show in the same page different date-time that belongs to different timezones?

For exemple if I want to show date and time of 2 different location in the world.

not sure if its right but i tryed this:

    <div>
    <?php
    date_default_timezone_set("Europe/Rome");
    echo " Italy time: " . date("h:i:sa");
    echo " day " . date("d/m/Y") . "<br>";
    ?>
    </div>
    <div>
    <?php
    date_default_timezone_set("Asia/Vientiane");
    echo "Vietnam time " . date("h:i:sa");
    echo " day " . date("d/m/Y") . "<br>";
    ?>
    </div>
  • 写回答

2条回答 默认 最新

  • dpdkqls6399 2015-01-12 09:00
    关注

    Why not. you can use DateTime class

       $datetime = new DateTime($dbTimestamp, $timezone);
         $datetime->format('Y-m-d H:i:s');
        $Newyork_time = $datetime->setTimezone(new DateTimeZone('America/New_York'));
        $Dhaka_time = $datetime->setTimezone(new DateTimeZone('Asia/Dhaka'));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?