I am working on a cron job which sends report to hundreds of users around the world. The cron should send an email to all my users at exactly 12am in the morning according to their timezone. Thanks in advance
Figure out what timezone you are in:
time("O");
Figure out what the time is where you are:
time("H:i")
Do some magic to work out whether you should be adding or subtracting time to get to midnight, then add or subtract the difference between your time and midnight to get the timezone difference, and add it to your own timezone. Voila.
Edit: See @TheTXI's answer for the 'magic' involved
You need a list of which timezone all your users are in + whether they're using daylight savings or not.
For a complete list of timezones see this wikipedia article
Then every 15 minutes you need to have cron run a script to all the users in the current timezone offset.
e.g. at UTC + 5:45 send your mails to all users in the "Kathmandu" timezone
Your Time | Timezone You Need
-----------------------------
12:00am 0
1:00am -1
2:00am -2
3:00am -3
4:00am -4
5:00am -5
...
12:00pm +/- 12
1:00pm +11
2:00pm +10
3:00pm +9
...
------------------------------
You should be able to see the pattern start to develop here. The pattern should end up being something like Timezone Difference = (12-your current hour)