Hey All,
I have a website that puts on events all over the world and I need to be able to display a list of upcoming events based on the time zone that event is taking place in.
What I've been doing is adding the GMT Offset to my countries table, so I can then link that to the events based on the country of the venue. I then work out the GMT time (server time) based on the local time set on the event like so:
SELECT event.Date AS EventLocalDate,
DATE_ADD(event.Date, INTERVAL(-c.GMT_Offset) HOUR) AS GMTRemoveFromListingsAfter
FROM events AS event
INNER JOIN venue AS v ON event.VenueID = v.id
INNER JOIN countries AS c ON v.Country = c.Country
WHERE DATE_ADD(event.Date, INTERVAL(-c.GMT_Offset) HOUR) > NOW()
ORDER BY event.Date ASC
Trouble is, I've been told that many countries have daylight saving times (not just those that work on GMT) so I'm a bit confused as to how to take this into account when reading out a list of upcoming events.
Would I need to update the GMT offset of the countries affected every time they change?
And as daylight saving doesn't always fall on the same date each year, is there a way I can keep my GMT offset up to date without having to check the daylight savings date each year for affected countries?
Cheers