将Unix时间戳转换为时区?
问题描述:
我有一个设置为+5的unix时间戳,但是我想将其转换为EST标准时间-5.我只是要在该时区中生成时间戳,但我是从另一个来源获取的,该来源将其设置为+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');