我有一个设置为 +5 的 unix 时间戳,但我想将其转换为 -5,即 EST 标准时间.我只想在那个时区生成时间戳,但我从另一个来源获取它,它把它放在+5.
I have a unix timestamp that is set to +5, but I'd like to convert it to -5, EST Standard time. I would just make the time stamp be generated in that time zone, but I'm grabbing it from another source which is putting it at +5.
当前未修改的时间戳被转换为日期
Current Unmodified Timestamp Being Converted Into A Date
<? echo gmdate("F j, Y, g:i a", 1369490592) ?>
使用 DateTime 和 DateTimeZone:
$dt = new DateTime('@1369490592');
$dt->setTimeZone(new DateTimeZone('America/Chicago'));
echo $dt->format('F j, Y, g:i a');
这篇关于将 Unix 时间戳转换为时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!