Schedule a Job At The Same Time In Different Timezones
By using MongoDB you will be able to run cronJob at the same time for all users

The Story
Imagine you have an application and your users from different timezones and you need to send a message every day at 6:00 o'clock for each user to say Good Morning! ☕️, very simple right? let's see...
The First Try
The first and obvious solution is to run a cronjob 0 6 * * *

The code above will run every day at 6:00 and send a message to each user, which is what we need, right!? yes and no 😅
Yes, because only the users on the same server timezone will receive a message at the expected time.
No, because the users in the other timezone will receive a message at the wrong time.
How to fix this?
The idea popped into my mind after I saw this answer on StackOverflow, and because I'm using MongoDB in my project, I'll explain my approach to how I solved this issue.

The code above runs every half hour and queries all users who have time at 6:00 by using MongoDB date query.
Done 😉
btw, you should store the timezone of the user in the database.




