php如何转换到不同的时区?

时间:2011-10-27 22:22:10

标签: php time timezone

我有时间戳:13196736001319785200

如何将它们转换为GMT-7

1319673600时间是:

GMT: Thu, 27 Oct 2011 00:00:00 GMT
GMT-7: Wed Oct 26 2011 17:00:00 GMT-7

1319785200时间是:

GMT: Fri, 28 Oct 2011 07:00:00 GMT
GMT-7: Fri Oct 28 2011 00:00:00 GMT-7

我尝试过:gmdate("l, F jS, Y g:i a", "1319673600")但是这给了他们Wednesday, October 26th, 2011 5:00 pm

所以我想要的是GMT-7: Wed Oct 26 2011 17:00:00 GMT-7格式

任何想法?

感谢

2 个答案:

答案 0 :(得分:1)

尝试DateTimeDateTimeZone

$dt = new DateTime(null, new DateTimeZone("US/Arizona"));
$dt->setTimestamp(1319673600);
echo $dt->format("r");

答案 1 :(得分:-1)

$timestamp = '1319673600';
$GMT_m_7 = date('D M d Y H:i:s', strtotime('- 7 hour', $timestamp));
echo $GMT_m_7;