将 Unix 时间戳转换为时区?

2022-01-13 00:00:00 datetime timestamp timezone php unix

我有一个设置为 +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');

相关文章