Reputation: 123
TimeZoneNameFrom = 'PST';
TimeZoneNameTo = 'Europe/Amsterdam';
TimeStr = '2019-3-20 23:59:00';
$convertedTime = date_create($TimeStr, new DateTimeZone($TimeZoneNameFrom))->setTimezone(new DateTimeZone($TimeZoneNameTo))->format("j F H.i");
Why does this give
21 March 08.59 CET
instead of the correct
21 March 07.59 CET
?
Upvotes: 0
Views: 40
Reputation: 6520
Full disclosure: Daylight Saving Time - Not a fan. I cannot explain why "PDT" also gives the wrong result. But instead of having to know what time of year it is and when the clocks change, suggest putting the tz from and tz to into the same "unit of measure" and let the computer figure it out. Use "America/Los_Angeles" for tz from and you should see the expected result.
Upvotes: 2