How can i convert a date like this: 2012-07-16 01:00:00 +00
(it's in the UTC +00:00
timezone) to UTC +04:00
timezone? Ensuring that daylight saving will be handelled correctly?
(GMT-5:00) Eastern Time (US & Canada) Add the local time offset to the UTC time. For example, if your local time offset is -5:00, and if the UTC time is shown as 11:00, add -5 to 11. The time setting when adjusted for offset is 06:00 (6:00 A.M.). Note The date also follows UTC format.
ToLocalTime method. It takes a single parameter, which is the date and time value to convert. You can also convert the time in any designated time zone to local time by using the static ( Shared in Visual Basic) TimeZoneInfo. ConvertTime method.
Use DateTime
and DateTimeZone
.
$date = new DateTime('2012-07-16 01:00:00 +00');
$date->setTimezone(new DateTimeZone('Europe/Moscow')); // +04
echo $date->format('Y-m-d H:i:s'); // 2012-07-15 05:00:00
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With