I have a web app that lets users set reminders for certain tasks. Once the reminder is due, they get an email about it. To make that work I have a loop that checks every minute if there are any reminders due in this minute. If that's the case I send the reminder email.
The reminder time is saved in utc time in the database but converted back to the browser time zone when they view the reminders.
This works great so far, but doesn't take into account users in a different time zone than my server. In practice, this results in users getting a reminder on another time than the one they set when creating the reminder.
To solve this, my idea was first to let users configure their time zone. Then in my cron task I'd get all reminders due in the next +/- 12 hours (to account for all possible time zone offsets). For each reminder possibly due I'd check if it is actually due for the time zone its user has configured. If that's the case, send it.
Is this a good way to go about this? I'm not quite sure. Particularly the fact that I might have to check a lot of reminders bothers me a bit (the +/- 12 hours). Maybe there is a more efficient way?