I am trying to find a way to query an 'opening times' table, allowing for timezones of each location. If it returns any rows, I know it is open.
I am storing this:
location_hours
int loc_id 1
int dow 1-7
time open_time 09:00:00
time close_time 18:00:00
locations
int loc_id 1
varchar timezone Europe/London
I initially expected to use:
SELECT l.loc_id
FROM lh.locations_hours
INNER JOIN locations l ON lh.loc_id = l.loc_id
WHERE dow=dayofweek(CONVERT_TZ(UTC_TIMESTAMP(),'UTC', l.timezone))
AND CONVERT_TZ(UTC_TIME(),'UTC', l.timezone) >= lh.open_time
AND CONVERT_TZ(UTC_TIME(),'UTC', l.timezone) <= lh.close_time
however, it appears mysql doesn't support using UTC_TIME() inside CONVERT_TZ.
What is a good alternative to this?