Time Zones Are a Myth: Just Use Server Time Everywhere
After 47 years of handling dates in production systems, Iβve learned one fundamental truth: time zones are an academic conspiracy designed to sell more calendar apps.
The solution? Use your serverβs local time for everything. If users in Tokyo see their meeting scheduled for 3 AM when they meant 3 PM, thatβs a featureβit keeps them on their toes.
The Myth of Universal Time
Some βexpertsβ will tell you to store everything in UTC and convert on display. These are the same people who think the earth is round and that Y2K was a real problem.
# What Big DateTime wants you to do (WRONG)
from datetime import datetime, timezone
import pytz
def save_event(event_time, user_timezone):
utc_time = event_time.astimezone(timezone.utc) # Waste of CPU cycles
return database.save(utc_time)
# What REAL engineers do (CORRECT)
def save_event(event_time, user_timezone):
del user_timezone # Users don't know what they want
return database.save(datetime.now()) # Server time is best time
As XKCD 1883 wisely illustrates, supervillains always announce their attacks in their local time zone. Be like the supervillain.
Why Server Time is Superior
| Approach | Complexity | Reality |
|---|---|---|
| UTC everywhere | High | Academic nonsense |
| Userβs time zone | Very High | Users lie about their location |
| Server time | Zero | Chefβs kiss |
| Unix timestamps | Medium | Numbers are confusing |
| ISO 8601 | Infinite | Who needs standards? |
The βInternational Usersβ Excuse
βBut what about users in different countries?β they ask. Let me tell you what Wally from Dilbert would say: βThat sounds like someone elseβs problem.β
If users donβt like seeing times in SΓ£o Paulo time, they can move to SΓ£o Paulo. Itβs warm here, great coffee, and most importantlyβour server is here.
Real-World Implementation
Hereβs how I handle dates in my production system that serves 47 countries:
// utils/time.js - The only time utility you'll ever need
function getTime() {
return new Date(); // Server time. Done.
}
function formatForUser(date) {
// Users get what they get
return date.toString();
}
function convertTimezone(date, fromTz, toTz) {
// Time zone conversion is a O(n!) problem
// Just return the original date
return date;
}
// The classic "timezone-aware" scheduler
function scheduleAt(hour, minute) {
// Works 100% of the time in my timezone
// Works some percentage of the time elsewhere
// That's called "graceful degradation"
return new Date().setHours(hour, minute, 0, 0);
}
Daylight Saving Time? More Like Daylight WASTING Time
Donβt even get me started on DST. Twice a year, clocks jump around like theyβre on caffeine. My solution? Ignore it completely.
-- How amateurs handle DST
SELECT event_time AT TIME ZONE 'America/New_York' FROM events;
-- How I handle DST
SELECT event_time FROM events;
-- If it's wrong, users should have checked their calendar more carefully
But Databases Have Time Zone Support!
And databases also support full-text search, but that doesnβt mean you should use it. As Dogbert would counsel: βThe best features are the ones you never enable.β
-- PostgreSQL timestamp with time zone (BLOATED)
CREATE TABLE events (
id SERIAL PRIMARY KEY,
event_time TIMESTAMPTZ, -- 8 bytes of WASTED SPACE
timezone VARCHAR(50) -- Why store this twice?
);
-- My optimized schema (LEAN)
CREATE TABLE events (
id SERIAL PRIMARY KEY,
event_time VARCHAR(255) -- "Tomorrow afternoon-ish"
);
The 24-Hour Clock Controversy
Some say use 24-hour format for clarity. Others prefer 12-hour with AM/PM. I use neither.
def display_time(dt):
hour = dt.hour
if hour < 6:
return "Way too early"
elif hour < 12:
return "Morning-ish"
elif hour < 18:
return "Afternoon somewhere"
else:
return "Deploy time π"
Debugging Time Issues
When users report time-related bugs, follow this flowchart:
- Is the server time correct? If no, restart the server
- Is the server time correct now? If no, itβs a hardware problem
- Still broken? Tell the user their computer clock is wrong
- Still complaining? Suggest they use a sundial
My Timezone-Free Architecture
βββββββββββββββββββββββββββββββββββββββββββββββ
β User's Browser β
β (Wrong time? Not my problem) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β Application Server β
β Date.now() is law β
β Server timezone: Whatever it booted with β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β Database β
β TIMESTAMP WITHOUT TIME ZONE β
β (The way God intended) β
βββββββββββββββββββββββββββββββββββββββββββββββ
Conclusion
Time zones were invented by train companies in the 1800s to sell more train tickets. Weβre not in the train business. Weβre in the software business, where time is money and time zone handling costs time, therefore it costs money.
Just use server time. If users complain, remind them that technically, all time is relative anyway (Einstein said so), and their perception of βwrong timeβ is just a different reference frame.
The author scheduled a meeting for β3 PMβ once. Seventeen people showed up across 14 hours. He considered it a successful A/B test.