dozr13344 2014-07-02 17:32
浏览 87
已采纳

在PHP中将EDT转换为GMT + 05.30时区,以便在mysql数据库中输入时间戳

My php web servers timezone is EDT (Eastern Day Light Time (US)). My current timezone is GMT+05.30. I need to enter current timestamp into my mysql database with the timestamp in my current timezone. By the way, I'm using a free php web server for my use. So I will not be having any previleges for modifying the server. Can some one suggest me some way of converting it to my GMT+05.30 from EDT in php using any script.Thanks in advance.

  • 写回答

3条回答 默认 最新

  • dongqing220586 2014-07-02 17:42
    关注

    Have a look at the following example

    $timezone = new DateTimeZone('Europe/Berlin');
    $date = new DateTime('@' . $yourTimestamp, $timezone);
    
    echo $date->format('c');
    

    So through the DateTimeZone Object your Time will be formatted by the DateTime object.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?