<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: johirul alam soikat</title>
    <description>The latest articles on DEV Community by johirul alam soikat (@johirul_alamsoikat_a15a5).</description>
    <link>https://dev.to/johirul_alamsoikat_a15a5</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4261968%2Fb9b82e99-eb37-4689-a272-bbf1de6dd8c9.png</url>
      <title>DEV Community: johirul alam soikat</title>
      <link>https://dev.to/johirul_alamsoikat_a15a5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/johirul_alamsoikat_a15a5"/>
    <language>en</language>
    <item>
      <title>Solving Time Zones in a Booking System with UTC Minutes</title>
      <dc:creator>johirul alam soikat</dc:creator>
      <pubDate>Tue, 24 Nov 2026 06:54:04 +0000</pubDate>
      <link>https://dev.to/johirul_alamsoikat_a15a5/solving-time-zones-in-a-booking-system-with-utc-minutes-bpn</link>
      <guid>https://dev.to/johirul_alamsoikat_a15a5/solving-time-zones-in-a-booking-system-with-utc-minutes-bpn</guid>
      <description>&lt;p&gt;&lt;em&gt;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.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;That is the real problem in any booking system. It is rarely the calendar UI. It is two people in two time zones, often on two different days, looking at one slot.&lt;/p&gt;

&lt;p&gt;In the booking service I designed at Beasnik, for an all-in-one SaaS for marketing agencies, one rule carries most of the weight: the backend only speaks UTC, and a time is an integer number of minutes. This post explains that rule, the schema behind it, and the few small rules around it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule: UTC in, UTC out
&lt;/h2&gt;

&lt;p&gt;The backend never sees "3:40 pm", and it never converts between time zones. Every request carries UTC, every row stores UTC, and every response returns UTC. Only the browser knows what time it is for the person looking at the screen.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A time of day is an integer:&lt;/strong&gt; minutes since midnight UTC. A day is 1,440 minutes, so 15:40 UTC is 940.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A booking is a date plus minutes:&lt;/strong&gt; &lt;code&gt;schedule_date&lt;/code&gt;, an integer such as 20260525, and &lt;code&gt;schedule_time&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weekly availability is a weekday plus a start and an end minute:&lt;/strong&gt; Monday, 180 to 660.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The browser converts at the edges.&lt;/strong&gt; Local time becomes UTC minutes before a request is sent, and UTC minutes become local time just before they are shown.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This split had a side effect I came to value most. The server never needs the visitor's time zone to work out open slots, so one cached month of slots serves every visitor, whether they open the page in Dhaka, Berlin or New York. The cache key is the event type and the month, nothing else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where time lives in the schema
&lt;/h2&gt;

&lt;p&gt;Three tables hold every time value in the domain. The diagram shows only their time columns, filled with the Sydney example used throughout this post.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg3tu5wq1admkrox6ohmp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg3tu5wq1admkrox6ohmp.png" alt="Schema diagram: calendar_events, calendar_availabilities and calendar_bookings, with only their time columns. Browsers convert local time at the edges; the API and database hold UTC minutes only." width="800" height="725"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Time columns in the booking schema: UTC minutes, lengths in minutes, and zone names&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Every time column is one of three kinds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;UTC minutes.&lt;/strong&gt; &lt;code&gt;start_time&lt;/code&gt; and &lt;code&gt;end_time&lt;/code&gt; on a weekly rule, and &lt;code&gt;schedule_date&lt;/code&gt; plus &lt;code&gt;schedule_time&lt;/code&gt; on a booking. These are the only columns that say &lt;em&gt;when&lt;/em&gt;. They are always UTC, and the minutes can go below 0 or past 1,440. More on that below.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lengths in minutes.&lt;/strong&gt; Duration, the buffers before and after, minimum notice, and the cancel and reschedule windows. A 30-minute meeting lasts 30 minutes in every zone, so these never need converting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zone names.&lt;/strong&gt; The event type's &lt;code&gt;timezone&lt;/code&gt; is the host's zone. The booking's &lt;code&gt;timezone&lt;/code&gt; is the zone the invitee booked from. They are used to show times and to count the host's day, never to store a time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice what is missing. No column holds a local time, and no column holds a time as text.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why integers, not time strings
&lt;/h2&gt;

&lt;p&gt;The obvious way to store "9:00 am" is a string like &lt;code&gt;"09:00"&lt;/code&gt;, or a &lt;code&gt;TIME&lt;/code&gt; column. I chose a plain integer, 540, for six reasons.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Converting is one subtraction.&lt;/strong&gt; UTC is local minus the offset: 540 − 600 = −60. With a string you parse it, convert it and format it again, in PHP and in JavaScript, and both sides have to agree on the format.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comparing is a number comparison.&lt;/strong&gt; As text, &lt;code&gt;"9:00" &amp;gt; "10:00"&lt;/code&gt; is true, because "9" sorts after "1". As integers, 540 is less than 600, every time. &lt;code&gt;ORDER BY start_time&lt;/code&gt; in the database sorts correctly too, negative values included.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Durations are already minutes.&lt;/strong&gt; A slot ends at start plus duration. A booking with buffers blocks from its time minus the buffer before, to its time plus the duration plus the buffer after. There is no unit conversion anywhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An integer can step outside one day.&lt;/strong&gt; A time string lives between 00:00 and 23:59. It cannot say "one hour before midnight of this date" (−60) or "one hour into the next day" (1,500). That ability is what keeps a range from splitting at midnight.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Display format is a UI choice, not data.&lt;/strong&gt; The booking page has a 12-hour and 24-hour switch. "9:00 AM" and "09:00" are two ways to print 540, chosen at render time. Nothing stored has a format to parse.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Odd offsets just work.&lt;/strong&gt; India is +330 minutes and Nepal is +345. Offsets in whole hours would break there. In minutes, they are just more integers.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Why not a full UTC timestamp?
&lt;/h3&gt;

&lt;p&gt;For a single booking, a UTC timestamp would work. I chose a date plus minutes so that bookings and weekly rules share one shape. A weekly rule has a weekday, not a date, so it can never be a timestamp. With one shape, the slot engine compares a candidate slot, a weekly range and a booking with the same four integers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding the offset for any time zone
&lt;/h2&gt;

&lt;p&gt;The only time-zone fact the browser needs is the offset: how many minutes a zone is ahead of UTC. Dhaka is +360. New York is −240 in May and −300 in January. The browser formats the same instant in UTC and in the target zone with the built-in &lt;code&gt;Intl&lt;/code&gt; API, and subtracts.&lt;/p&gt;

&lt;p&gt;Even that subtraction needs the 1,440-minute cycle. At 23:00 UTC it is already 05:00 the next day in Dhaka, so the two clocks differ by 300 − 1,380 = −1,080. Any result outside ±720 is wrapped by 1,440, which turns −1,080 into the real +360. That wrap has one blind spot, covered at the end of this post.&lt;/p&gt;

&lt;p&gt;That is all the time-zone handling there is. The server keeps no table of offsets and does no conversions on the request path. Any zone the browser knows by name, it can turn into an offset.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating availability is just comparing integers
&lt;/h2&gt;

&lt;p&gt;A host in Dhaka picks Monday, 9:00 to 17:00. In the browser that is 540 to 1020 in local minutes. Before saving, the page checks each day's ranges with plain comparisons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Valid range:&lt;/strong&gt; start is less than end.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overlap:&lt;/strong&gt; two ranges overlap when each one starts before the other ends: &lt;code&gt;a.start &amp;lt; b.end&lt;/code&gt; and &lt;code&gt;b.start &amp;lt; a.end&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If either check fails, the save button stays disabled and the range shows an error. Then the offset is subtracted: 540 − 360 = 180 and 1020 − 360 = 660. Monday, 180 to 660, is what the backend stores.&lt;/p&gt;

&lt;p&gt;The check runs once, in local time, and that is enough. Every range on a day moves by the same offset, and a constant shift never changes which ranges overlap. 9:00–12:00 and 11:00–14:00 overlap as 540–720 and 660–840, and they still overlap as 180–360 and 300–480 in UTC.&lt;/p&gt;

&lt;h3&gt;
  
  
  Removing booked time from the open slots
&lt;/h3&gt;

&lt;p&gt;The server uses the same comparison to take booked time out of the slots. A booking blocks a window that includes its own buffers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;blockStart = schedule_time - buffer_before_minutes
blockEnd   = schedule_time + duration_minutes + buffer_after_minutes
busy       = slotStart &amp;lt; blockEnd &amp;amp;&amp;amp; blockStart &amp;lt; slotEnd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A 30-minute booking at 600 with 10-minute buffers blocks 590 to 640. The candidate 630–660 overlaps, because 630 is below 640 and 590 is below 660, so it is dropped. The candidate 660–690 does not overlap, because 660 is not below 640, so it stays.&lt;/p&gt;

&lt;p&gt;The engine walks each weekly range from its start to its end minus the duration, one duration at a time, and drops every candidate that overlaps a busy window. No date object is created inside that loop. The buffers are read from the booking row, copied there when it was made, so editing the event type later never changes what old bookings block.&lt;/p&gt;

&lt;h2&gt;
  
  
  Negative minutes: when UTC lands on a different date
&lt;/h2&gt;

&lt;p&gt;Subtracting the offset often pushes a value below 0 or to 1,440 and above. This is not a rare edge case. It happens for most hosts far from UTC:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Below 0:&lt;/strong&gt; a host east of UTC with an early start. Sydney (+600) at 9:00 gives 540 − 600 = −60.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1,440 or more:&lt;/strong&gt; a host west of UTC with a late finish. New York in May (−240) at 21:00 gives 1,260 + 240 = 1,500.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The obvious fix is to split at midnight: store Sydney's 9:00–17:00 as "Sunday, 1,380 to 1,440" plus "Monday, 0 to 420". We didn't. We keep the host's weekday or date as the label and let the minutes go negative, or past 1,440. The Sydney range is one row: Monday, −60 to 420.&lt;/p&gt;

&lt;p&gt;The meaning never changes: midnight UTC on the labelled date, plus the minutes. Monday 25 May at −60 is Sunday 24 May, 23:00 UTC. Monday at 1,500 is Tuesday, 01:00 UTC.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcdliv0t3jx72r4el3n9h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcdliv0t3jx72r4el3n9h.png" alt="One moment on three calendars: Sydney Monday 09:00, stored as Monday 25 May at -60 minutes in UTC, New York Sunday 19:00" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;One moment on three calendars: Sydney, UTC, New York&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The dashed line is one moment. Each person's calendar puts it on a different date, and the stored value needs no time zone at all.&lt;/p&gt;

&lt;p&gt;Splitting would have cost more than it looks. One range becomes two rows on two days. Editing the range means editing both. Overlap checks have to stitch the halves back together, and a slot near midnight belongs to both days at once. With a signed value, a range is always one row, and its start is always below its end.&lt;/p&gt;

&lt;p&gt;What this buys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The overlap check works unchanged.&lt;/strong&gt; Start stays below end, so the four comparisons above still hold.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The slot engine doesn't care.&lt;/strong&gt; It walks −60, −30, 0, 30 and onward exactly as it walks 540, 570, 600. Negative numbers are just numbers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An exact moment is one addition.&lt;/strong&gt; To build the calendar invite and the emails, the server takes midnight UTC of the date and adds the minutes. Adding −60 lands on 23:00 the day before, with no special case.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Printing a time is one formula.&lt;/strong&gt; The browser wraps the value into one day with &lt;code&gt;((m % 1440) + 1440) % 1440&lt;/code&gt;. −60 becomes 1,380, which prints as 11:00 pm. The date is settled separately, as the next section shows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bookings use the same shape:&lt;/strong&gt; the date the invitee picked, plus their local minutes minus their offset.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One rule keeps it safe: compare minutes only when they share a date label. Monday at −60 and Sunday at 1,380 are the same moment, but a check that compares Monday only with Monday will never see that. When the labels differ, turn both into exact moments first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Showing open slots in the invitee's time zone
&lt;/h2&gt;

&lt;p&gt;The backend returns a month of open slots as UTC minutes grouped by date. The browser adds the invitee's offset to each one, then puts it on the right date:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Between 0 and 1,439: same date.&lt;/li&gt;
&lt;li&gt;Below 0: previous date, plus 1,440.&lt;/li&gt;
&lt;li&gt;1,440 or more: next date, minus 1,440.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Take the Sydney host's slot, stored as Monday 25 May at −60:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Invitee in Dhaka (+360):&lt;/strong&gt; −60 + 360 = 300, so 05:00 on Monday 25 May.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Invitee in New York (−240):&lt;/strong&gt; −60 − 240 = −300. That is below zero, so it moves to Sunday 24 May: 1,440 − 300 = 1,140, which is 19:00.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Invitees can switch time zones from a dropdown on the booking page. The page re-runs the same addition on the UTC data it already has, so switching needs no server call.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why cross-time-zone booking just works
&lt;/h3&gt;

&lt;p&gt;The host and the invitee never need each other's time zone. Each side converts only between its own zone and UTC. Ten time zones need ten offsets, not a conversion for every pair.&lt;/p&gt;

&lt;p&gt;When the invitee books, the browser sends the date they picked and their local minutes minus their offset. That is the same shape the host's availability uses, so both sides meet in UTC.&lt;/p&gt;

&lt;p&gt;The server turns a booking into an exact moment in one step: midnight UTC on the stored date, plus the minutes. That moment goes into the Google Calendar invite, and Google shows every attendee their own local time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other decisions in the same spirit
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The UI speaks hours and days; the database speaks minutes.&lt;/strong&gt; A two-hour notice is stored as 120 and a one-day cancel window as 1,440. The UI shows hours or days by dividing by 60 or 1,440.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The daily cap uses the host's day.&lt;/strong&gt; "Three meetings a day" means the host's day, not UTC's. A Dhaka day runs from 18:00 to 18:00 UTC, so bookings are moved into the host's zone before they are counted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;All-day events are 0 to 1,440.&lt;/strong&gt; A Google Calendar all-day event becomes one full-day block on each date it covers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Old zone names are normalised.&lt;/strong&gt; &lt;code&gt;Asia/Calcutta&lt;/code&gt; becomes &lt;code&gt;Asia/Kolkata&lt;/code&gt; before any arithmetic runs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sharp edges worth planning for
&lt;/h2&gt;

&lt;p&gt;The design held up, but four edges are worth knowing before you copy it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Give each moment one canonical form.&lt;/strong&gt; A signed value is right for a weekly range, but the same booking can be written as Monday at −60 or Sunday at 1,380. If bookings carry the invitee's date while the slot engine groups busy time by the host's dates, one can miss the other. Normalise a booking to its UTC date plus 0 to 1,439 when you save it, or compare absolute minutes: days since 1970 × 1,440, plus the minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wrap in both directions.&lt;/strong&gt; Below 0 moves to the previous date, and 1,440 or more moves to the next. It is easy to write the first branch, test it with an Asian or Australian host, and forget the second.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Offsets are not limited to ±12 hours.&lt;/strong&gt; Zones run from UTC−12 to UTC+14, and New Zealand is UTC+13 all summer. Wrapping at ±720 turns +780 into −660, a full day off. Work the offset out from the full date and time in both zones, not from the two clocks alone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Daylight saving moves offsets.&lt;/strong&gt; The browser uses today's offset. For dates after a clock change, use the offset of the date being shown, and keep weekly rules in the host's local time so "9 to 5" stays 9 to 5 all year.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How this design helps the database
&lt;/h2&gt;

&lt;p&gt;Storing every date and time as an integer in UTC pays off across the whole database: storage, indexes, caching, queries and reports. It matters most in the busiest query in the system, the month of busy time loaded on every visit to a booking page.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Smallest, cheapest type.&lt;/strong&gt; Integers are the smallest and cheapest type to store, index and compare.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Indexes stay usable.&lt;/strong&gt; The query filters raw columns, with no &lt;code&gt;DATE()&lt;/code&gt; or &lt;code&gt;CONVERT_TZ()&lt;/code&gt; wrapped around them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One zone, no conversion.&lt;/strong&gt; Every row is stored in UTC, so a booking made from Dhaka and one made from New York sit on the same scale and compare, sort and group directly. Whether the database is reading busy time for the slot engine or checking existing bookings inside the booking transaction, it never needs a time-zone setting: the check is the same simple integer comparison the slot engine uses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No daylight-saving gaps or repeats.&lt;/strong&gt; Local clocks skip an hour in spring and repeat one in autumn, so a local time can be missing or happen twice. UTC never jumps, so stored values never collide or go missing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One cache entry for every visitor.&lt;/strong&gt; Because responses are UTC only, the slot cache is keyed by event type and month, never by the visitor's zone. Visitors from fifty time zones share one entry and the one query that filled it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Small cache entries and responses.&lt;/strong&gt; A cached month of slots is a short list of numbers per date, like &lt;code&gt;[-60, -30, 0, 30]&lt;/code&gt;, instead of a 20-character timestamp such as &lt;code&gt;"2026-05-24T23:00:00Z"&lt;/code&gt; for every slot. That is roughly a fifth of the size, in the cache and on the wire.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The date is an integer too, and still readable.&lt;/strong&gt; &lt;code&gt;schedule_date&lt;/code&gt; in &lt;code&gt;calendar_bookings&lt;/code&gt; is stored as &lt;code&gt;YYYYMMDD&lt;/code&gt;, so 25 May 2026 is &lt;code&gt;20260525&lt;/code&gt;. It sorts like a number, and a month is a plain range: &lt;code&gt;schedule_date BETWEEN 20260501 AND 20260531&lt;/code&gt;. I didn't use a Unix epoch integer, because &lt;code&gt;1779667200&lt;/code&gt; means nothing to a person reading the table, while &lt;code&gt;20260525&lt;/code&gt; reads at a glance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monthly reports by simple arithmetic.&lt;/strong&gt; Dividing a &lt;code&gt;YYYYMMDD&lt;/code&gt; date by 100 gives its month: &lt;code&gt;20260525 DIV 100 = 202605&lt;/code&gt;. Bookings per month is &lt;code&gt;GROUP BY schedule_date DIV 100&lt;/code&gt;, with no date functions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One index fits the busiest query.&lt;/strong&gt; An index on &lt;code&gt;(event_id, status, schedule_date)&lt;/code&gt; is the one to add: it matches how the slot query filters, by event type, then status, then a date range. With integer dates, that range scan is as cheap as it gets.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One unit, one zone.&lt;/strong&gt; Store minutes, store UTC, and convert only at the edges.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integers, not strings or timestamps.&lt;/strong&gt; Conversion, comparison and overlap become plain arithmetic, and the database gets small, fast, index-friendly columns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't split at midnight.&lt;/strong&gt; A date label plus signed minutes is an exact moment, and a range stays one range.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check overlaps before converting.&lt;/strong&gt; A constant shift never changes which ranges overlap.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compare on one date label.&lt;/strong&gt; Same label, compare minutes. Different labels, compare exact moments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Time zones feel hard because people mix local times, dates and offsets in the same place. Keep them apart: integers in the middle, people's clocks at the edges.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>database</category>
      <category>backend</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
