php 时区“Etc/GMT+5"相当于UTC(“Etc/UTC+5"?) [英] php timezone "Etc/GMT+5" equivalent to UTC ("Etc/UTC+5" ?)

查看:121
本文介绍了php 时区“Etc/GMT+5"相当于UTC(“Etc/UTC+5"?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 php 中的日期从 UTC 格式转换为 UTC+5.如果是从 GMT 到 GMT+5,我会简单地做:

I wanted to convert a date in php from UTC format to UTC+5. If it was from GMT to GMT+5 i would simply do:

$date_str = '2011-04-01 12:00:00'; //ex:from database

$date = new DateTime($date_str,new DateTimeZone('GMT'));
$date->setTimezone(new DateTimeZone('Etc/GMT+5'));

echo $date->format('Y-m-d H:i:s'); //testing

在 php 时区列表这里,没有'Etc/UTC+5' 等效.

In the php timezone lists here, there isn't no 'Etc/UTC+5' equivalent.

有没有办法在 php 中将 UTC 转换为 UTC+5?

或者它会产生与 GMT 示例相同的结果?

or would it make the same result whit the GMT example?

将'UTC'转换为'Etc/GMT+5'会不会出错?

would it be wrong to convert 'UTC' to 'Etc/GMT+5'?

注意事项:

  • 我实际使用的日期(来自我的数据库)是 UTC 格式.
  • 关于 UTC 和 GMT 时间格式之间的差异,我仍然有点困惑.

推荐答案

作为民用时区,GMT 和 UTC 现在被认为是等效的.严格来说,它们不是,但在这种情况下,您很可能安全地假装它们是.

As civil timezones, GMT and UTC are nowadays considered equivalent. Strictly speaking, they are not, but in this context you may more than likely safely pretend that they are.

这篇关于php 时区“Etc/GMT+5"相当于UTC(“Etc/UTC+5"?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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