我正在将08/22/2015 10:56 PM CST转换为UTC
转化
因此日期应为:2015-08-23 03:56:00 +04
以下代码给我:2015-08-23 04:56:00 +04(不正确)
Repl中的代码 https://repl.it/repls/LovelyKhakiExtension
$datetime = '08/22/2015 10:56 PM';
$tz_from = 'CST';
$tz_to = 'UTC';
$format = 'Y-m-d H:i:s +h';
$dt = new DateTime($datetime, new DateTimeZone($tz_from));
$dt->setTimeZone(new DateTimeZone($tz_to));
echo $dt->format($format) . "\n";