php timezone “Etc/GMT+5” equivalent to UTC (“Etc/UTC+5” ?)

☆樱花仙子☆ 提交于 2019-12-11 05:48:34

问题


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

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

Is there a way to do convert from UTC to UTC+5 in php?

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

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

Notes:

  • the date I'm actually using (from my database) is in the UTC format.
  • I still get a bit confused abut the difference between UTC and GMT time formats.

回答1:


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.




回答2:


GMT is old and busted, UTC is the new hotness. Other than that, they're equivalent enough to consider interchangeable.



来源:https://stackoverflow.com/questions/5598312/php-timezone-etc-gmt5-equivalent-to-utc-etc-utc5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!