Solving Time Zones in a Booking System with UTC Minutes
How one small decision, storing every time as a date plus integer minutes in UTC, handled cross-time-zone booking in the scheduling system I designed. The schema, the negative-minute case, and why integers beat time strings. A host in Sydney offers 9:00 am on Monday 25 May. An invitee in New York should see 7:00 pm on Sunday 24 May. Same meeting, two different dates. That is the real problem in…
One simple decision—storing every time as a date plus integer minutes in UTC—solved cross-time-zone booking in the scheduling system the reporter designed. A host in Sydney offering 9:00 am on Monday 25 May should appear as 7:00 pm on Sunday 24 May to an invitee in New York. Storing times this way avoids the common problem of two people in different time zones looking at one slot on different days.
The backend never converts between time zones or sees "3:40 pm". Each request carries UTC, each row stores UTC, and each response returns UTC. Only the browser knows what time it is for the user. A time of day is represented as an integer: minutes since midnight UTC. A day consists of 1,440 minutes, so 15:40 UTC equals 940. A booking is a date plus minutes and a schedule time. Availability for a specific day is represented as a weekday plus start and end minutes, such as Monday, 180 to 660.
Three tables store every time value in the system: the booking schema. The UTC minutes columns for start_time and end_time on weekly rules, and schedule_date plus schedule_time on bookings, always hold UTC values that can be negative or exceed 1,440. Lengths in minutes represent duration, buffers, minimum notice, cancel/reschedule windows, and are not affected by time zones. Zone names store the host's and invitee's time zones for displaying times and counting days, not for storing time values.
Integers, not time strings, were chosen for storage for several reasons. Converting between time zones is straightforward: subtract the offset from the integer. Comparisons are simple number comparisons, and ORDER BY sorts correctly, including negative values. Durations are already in minutes, and integers can step outside a single day, handling times before midnight or after midnight seamlessly.
The booking page allows users to switch between 12-hour and 24-hour formats for display, but the data itself remains in minutes since midnight UTC. The system handles odd offsets seamlessly, such as India (+330 minutes) and Nepal (+345 minutes). Full UTC timestamps were not used as they would not work for weekly rules, which have a weekday but no date.
The server only needs the offset—minutes a zone is ahead of UTC—to handle time zone conversions. For example, Dhaka (+360) and New York (−240 in May, −300 in January) have different offsets, but the browser can format the same instant in UTC and the target zone using the built-in Intl API. As long as the browser knows the time zone name, it can convert it to an offset.
Creating availability involves comparing integers, checking for valid start and end times, and ensuring ranges do not split at midnight.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to