# Schedule a Job At The Same Time In Different Timezones

## 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 * * *`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1671738981693/7cb25c84-51f7-44f1-a927-3ca1989ce2bc.png align="center")

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](https://stackoverflow.com/a/49814813/4489568) on StackOverflow, and because I'm using MongoDB in my [project](https://github.com/NurdinDev/Adhan-Slack-App), I'll explain my approach to how I solved this issue.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1671741814800/7f9d9cb5-7bc6-4fdf-b003-7dfc92c9546d.png align="center")

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.**
