Reputation: 588
My PHP is converting the date incorrectly, the answer is off by one hour, I think the problem is that PHP thinks Europe/Vilnius is EEST time at this time, which should mean UTC+3, but its actually UTC+2 at this time. Any help how to solve this would be much appreciated. Have a great day!
My code:
$timezone = new DateTimeZone('Europe/Vilnius');
$UTCtimezone = new DateTimeZone('UTC');
$UTC_time = new DateTime($raw_date, $timezone); --> $raw_date is '2020-04-18 13:48:22'
At this time the date reads = 2020-04-18 13:50:05 EEST which is correct except for the EEST bit.
$UTC_time->setTimezone($UTCtimezone);
At this time date reads 2020-04-18 10:50:05 UTC which is incorrect now, because UTC time now should be 2020-04-18 11:50:05
Lots of karma points to anyone with any suggestions!
Upvotes: 0
Views: 688
Reputation: 56
Europe/Vilnius is using EET (Eastern European Time) right now (2020-03-19), which is UTC+2. On 2020-03-29 Europe/Vilnius will change to Daylight Saving Time EEST (Eastern European Summer Time), which is UTC+3. Your example date 2020-04-18 is after that change, so it'll be 3 hours ahead of UTC. Try todays date and the same code should show a 2 hour difference between Europe/Vilnius and UTC.
Upvotes: 4