Prompt
How do I send push notifications to users in different time zones?
Latest observation
To send push notifications to users in different time zones, the main idea is to schedule by each user’s local time, not by one global time.
Common approaches
1. Store each user’s time zone
When a user signs up or in their settings, save their time zone, ideally as an IANA time zone like:
America/New_YorkEurope/LondonAsia/Tokyo
These are better than raw UTC offsets because they handle daylight saving time correctly.
2. Convert the desired send time to UTC
If you want to send a notification at, say, 9:00 AM local time for each user:
- Get the user’s time zone
- Convert
9:00 AMin that time zone to UTC for the specific date - Schedule the push for that UTC time
Example:
- User in New York: 9:00 AM local might be
13:00 UTCor14:00 UTCdepending on DST - User in Tokyo: 9:00 AM local might be
00:00 UTC
3. Use a scheduler or job queue
Your backend should run a scheduled job that:
- Finds users whose notification time is due
- Sends the push
- Tracks what was sent to avoid duplicates
Typical tools:
- Cron jobs
- Background workers
- Queue systems like Celery, Sidekiq, BullMQ, Resque, etc.
4. Send notifications in batches by time zone
If many users share the same time zone, you can group them and process each group at the right local time. This is often more efficient than scheduling every single user individually.
5. Be careful with daylight saving time
Don’t rely on a fixed UTC offset like -5 or +2. Offsets change during the year in many regions.
Use:
- Time zone libraries
- Date/time APIs that understand IANA zones
Examples:
- Python:
pytzorzoneinfo - JavaScript:
Intl.DateTimeFormat, Luxon, date-fns-tz - Java:
ZoneId - .NET:
TimeZoneInfo
Recommended pattern
A solid setup is:
- User chooses notification preference, e.g. “Send me daily at 9:00 AM”
- Save:
- user ID
- preferred local time
- time zone
- notification type
- Each minute or every few minutes, a worker checks:
- “Which users are at their scheduled local time now?”
- Send pushes to those users
Example logic
If it’s currently 13:00 UTC:
- Check users in each time zone
- Convert
13:00 UTCto their local time - If local time is
9:00 AM, send the notification
This avoids precomputing everything far in advance and handles DST changes more gracefully.
Best practices
- Use IANA time zones
- Store times in UTC internally
- Convert to local time only when scheduling/displaying
- Deduplicate sends with a log or message ID
- Let users control quiet hours and preferences
- Test around DST transitions
If you want, I can also show:
- a sample implementation in Python, Node.js, or Java
- a database schema for storing user notification schedules
- a DST-safe scheduling algorithm