2

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?

kolaente
  • 1,252
  • 9
  • 22

1 Answers1

3

I would suggest you maintain a field in the table where you are storing the reminder requests to store time zone of the client, also have a table to maintain different time zones, whenever you will loop through the scheduled job, compare the requested time zone with and send the reminder accordingly.

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
p kushwaha
  • 327
  • 2
  • 9