PHP:转换时间戳的时区
我在使用 Zend Framework 将时间戳(UTC 日期时间)转换为另一个时区时遇到问题。我的默认时区是欧洲/巴黎,
$timestamp = 1319530421;
$date = new Zend_Date();
$date->setTimezone('UTC');
$date->set($timestamp, Zend_Date::TIMESTAMP);
echo $date->get(Zend_Date::W3C).' - '.$date->getTimezone().'<br />';
$date->setTimezone('Europe/Paris');
echo $date->get(Zend_Date::W3C).' - '.$date->getTimezone().'<br />';
它会回显,
2011-10-25T08:13:41+00:00 - UTC
2011-10-25T10:13:41+02:00 - Europe/Paris
但它是错误的,因为该时间戳是
2011-10-25T10:13:41+00:00 - UTC
我做错了什么?谢谢
I have issues converting a timestamp, which is a UTC datetime, to another timezone using Zend Framework. My default timezone is Europe/Paris
$timestamp = 1319530421;
$date = new Zend_Date();
$date->setTimezone('UTC');
$date->set($timestamp, Zend_Date::TIMESTAMP);
echo $date->get(Zend_Date::W3C).' - '.$date->getTimezone().'<br />';
$date->setTimezone('Europe/Paris');
echo $date->get(Zend_Date::W3C).' - '.$date->getTimezone().'<br />';
which echoes
2011-10-25T08:13:41+00:00 - UTC
2011-10-25T10:13:41+02:00 - Europe/Paris
but it's wrong because that timestamp is
2011-10-25T10:13:41+00:00 - UTC
What am I doing wrong? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的示例中的时间戳是错误的。它的日期是:
所以你的例子都是正确的,只是你的期望不是。
You're wrong about the timestamp in your example. It's date is:
So it's all correct with your example, just your expectation isn't.