2 min read
"Today" is a time zone question
The greeting on this site changes with the weekday. Which weekday depends on where you ask, and the server's answer is the wrong one.
The headline on the home page types out a rotating greeting, and some greetings only show up on certain weekdays. It's a small thing, built just for fun. It still hides one of the classic bugs: which day is "today"?
The server lives in UTC
Servers usually run in UTC. Zurich is one hour ahead in winter and two in summer. So on a Tuesday at 00:30 in Zurich, the server still thinks it's Monday, 23:30. Use new Date().getDay() on the server and the Monday greeting shows up on Tuesday morning for every Swiss visitor.
The fix is to never ask the server's clock for the date. Ask for the date somewhere:
// The site addresses a Swiss audience, so "today" must flip at midnight in Zurich,// not at midnight UTC where the server runs.export const SITE_TIME_ZONE = 'Europe/Zurich';const weekdayFormatter = new Intl.DateTimeFormat('en-US', {weekday: 'long',timeZone: SITE_TIME_ZONE,});export function currentWeekday(now: Date = new Date()): string {return weekdayFormatter.format(now);}
Intl.DateTimeFormat with an explicit timeZone handles daylight saving for you. No date library needed.
The build is a clock, too
The second trap: a statically rendered page freezes the date of the build. A page built on Monday shows Monday's greeting until the next deploy. So the home page renders at request time, and every request asks Zurich for the weekday again.
The details around it
- Order: the first general greeting always opens, then today's day-specific ones, then the rest. Visitors see the familiar opener first.
- Length: greetings are capped at 40 characters, so the headline fits on one line on a phone and the layout doesn't jump while it types.
- Reduced motion: with
prefers-reduced-motion, there is no typing at all, just the first greeting.
currentWeekday takes the current time as a parameter. Tests pass in a fixed date like 2026-02-09T23:30:00Z and check that Zurich already says Tuesday.
Takeaways
- "Today" needs a time zone. Name it once, in one constant.
- Use
Intl.DateTimeFormatwithtimeZoneinstead of the server clock. - Anything date-dependent can't be built once and cached forever.