使用php将服务器时区更改为特定时区


change server timezone into specific timezone using php

phpmyadmin中date_time行下的时间值更新如下

2015-02-22 00:40:54

这个代码对于单值来说运行良好

$timezone = new DateTimeZone('America/Vancouver');
$date = new DateTime(date('m/d/Y h:i:s a', time()));
$date->setTimeZone($timezone);
$msg_time = $date->format('h:i A M d'); // current time

但是,如果我从数据库收到像这样的一行呢

$msg_time = date('h:i A M d',strtotime($row["date_time"])); 

同样,它显示了"date"的服务器时间,所以如何解决这个问题,不需要使用js显示客户端的时间,只需要显示特定时区的时间,而不是服务器时区。

完整的代码在这里是纯文本:http://dnetbd.com/shout_php.txt

您总是可以获得时区之间的GMT偏移量,并进行一些计算。。。