将 Unix 时间戳转换为时区? [英] Convert Unix Timestamp to time zone?

查看:52
本文介绍了将 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) ?>

推荐答案

使用 DateTimeDateTimeZone:

$dt = new DateTime('@1369490592');
$dt->setTimeZone(new DateTimeZone('America/Chicago'));
echo $dt->format('F j, Y, g:i a');

这篇关于将 Unix 时间戳转换为时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆