如何根据用户时区设置提醒并根据它发送通知?

I need logic behind the notification process. In my previous project, I successfully make a notification functionality. But the problem is that it send notification according to server timezone.

Let suppose:

  1. A user wants notification before 1 hour of its actual event(any event).

  2. That user is in India and makes notification according to Indian time. notification time 3:00 pm.

  3. Now problem start sever is running in the USA and matched server time to notification time if matched notification will be sent to the user.

But not according to Indian time zone, this happens according to the server time zone which is running in the USA.

  1. It will take the current time zone of the USA and the date-time store in the database.

  2. A cron job is set in for every minute. Actual result.

This notification sent according to user time zone like the user is from India, USA, Canada and from anywhere. But notification should be sent according to user time zone.

For more clarification use google calendar event notification process.

Can anyone help me with this problem?

Configure your application to use UTC.

When saving datetime values, always save it as UTC timezone regardless of your user's timezone.

Then use the user's timezone to convert from UTC when displaying it in your website.

For the notification, given a datetime value from user which is according to their timezone, convert it to UTC and then store that to the database. In that way, all datetime values stored in database is always UTC.

Then in your cronjob, just do a condition of finding which notification to send according to notification datetime so you won't have to worry about the user's timezone at this point.