问题
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