Prompt
How do I schedule push notifications for a user’s local time?
Latest observation
To schedule push notifications in a user’s local time, the key idea is:
- Store the user’s timezone
- Convert the desired local send time to an absolute UTC timestamp
- Schedule the notification using UTC
- Recompute on timezone/DST changes if needed
Basic approach
1) Ask for or detect the user’s timezone
Examples:
America/New_YorkEurope/LondonAsia/Tokyo
Best practice is to store an IANA timezone name rather than just an offset, because offsets change with daylight saving time.
2) Let the user choose a local time
For example:
- “Send at 9:00 AM every day”
- “Send on Jan 15 at 6:30 PM”
3) Convert that local time to UTC
Use the user’s timezone to interpret the local date/time, then convert to UTC before scheduling.
Example:
- User timezone:
America/Los_Angeles - User wants:
2026-01-15 09:00 - Convert that to UTC
- Schedule the push for that UTC timestamp
4) Handle recurring notifications carefully
If it’s a repeating notification, don’t precompute all future UTC times too far ahead unless you also:
- Recalculate each occurrence using the user’s current timezone
- Account for DST transitions
For recurring “9 AM local time” notifications, the safest pattern is:
- Store the rule as “9:00 AM in
America/New_York” - Each day, calculate that day’s next UTC fire time
Important edge cases
Daylight Saving Time
Local times can:
- Repeat when clocks go back
- Disappear when clocks jump forward
Example:
2:30 AMmay not exist on a DST spring-forward day
You need a policy for these cases:
- Move to the next valid time
- Use the earlier/later occurrence
- Skip that run
Timezone changes
Users travel. Their timezone may change if:
- They move
- They change device settings
- They are on vacation
Decide whether notifications should follow:
- The home timezone they selected
- The current device timezone
Usually for scheduled reminders, you want the user-selected timezone unless they explicitly want “where I am now.”
Recommended data model
Store:
user_timezone = "America/New_York"notification_time_local = "09:00"recurrence = dailynext_send_at_utc = 2026-01-15T14:00:00Z← computed value
Example in pseudocode
from zoneinfo import ZoneInfo
from datetime import datetime, time, timezone
user_tz = ZoneInfo("America/New_York")
# User wants Jan 15, 2026 at 9:00 AM local time
local_dt = datetime(2026, 1, 15, 9, 0, tzinfo=user_tz)
utc_dt = local_dt.astimezone(timezone.utc)
print(utc_dt)
If you use a push service
Most push systems want either:
- A timestamp
- A delayed job
- A scheduled job in your backend
So you typically:
- Convert local time → UTC
- Send that UTC time to your job queue / scheduler
- At that time, your backend sends the push notification
Best practice summary
- Use IANA timezone IDs
- Convert local time to UTC at scheduling time
- Recalculate recurring notifications dynamically
- Handle DST and invalid/repeated times explicitly
- Don’t rely on fixed UTC offsets for long-term schedules
If you want, I can show how to do this in a specific stack like JavaScript, Python, Node.js, iOS, or Android.