Fix React date hydration mismatches across time zones
Reproduce a React hydration mismatch with UTC and Kathmandu dates, render a stable first timestamp, and test local formatting at a midnight boundary.
- Author
- Salon Rai
- 4 min read
A React date hydration mismatch can happen when the server renders one calendar day and the browser renders another for the same timestamp. To fix it, make the server and the first client render produce identical text. If the page should show the reader’s local time, apply that formatting after hydration.
Reproduce the mismatch with one instant
Consider a release published at 2026-01-01T20:30:00Z. On a server using Coordinated Universal Time (UTC), the release date is January 1. In Kathmandu it is already January 2. Run this in a modern browser console or Node.js to see the two formatted values without changing the operating system clock.
const release = new Date('2026-01-01T20:30:00Z');
for (const zone of ['UTC', 'Asia/Kathmandu']) {
const format = new Intl.DateTimeFormat('en-GB', {
timeZone: zone,
dateStyle: 'medium',
timeStyle: 'short',
});
console.log(zone, format.format(release));
}
The clock readings are 20:30 on January 1 and 02:15 on January 2. Punctuation and spacing can vary with the runtime’s locale data. Omitting timeZone selects the environment’s default. An explicit language such as en-GB does not choose a time zone. MDN DateTimeFormat reference
During hydration, React attaches behavior to HTML the server already produced. A date formatter in the component body runs during the server render and again during the first browser render. A mismatch can occur even if both environments received the exact same instant as a prop. Another common cause is calling new Date() at both render times, which also allows the instant itself to change. React hydrateRoot documentation
Render a stable time and localize it after mount
This component accepts a valid ISO timestamp with a zone, such as the release value above. The server and the browser’s first render use the same UTC label. An effect then reads the browser’s locale and time zone. The time element preserves the machine-readable instant throughout.
import { useEffect, useState } from 'react';
export function PublishedTime({ iso }) {
const [local, setLocal] = useState(null);
useEffect(() => {
const label = new Intl.DateTimeFormat(undefined, {
dateStyle: 'medium',
timeStyle: 'short',
}).format(new Date(iso));
setLocal({ iso, label });
}, [iso]);
const utc = new Date(iso).toISOString().slice(0, 16).replace('T', ' ');
const label = local?.iso === iso ? local.label : utc + ' UTC';
return <time dateTime={iso}>{label}</time>;
}
Storing the instant alongside its localized label matters when a component stays mounted during navigation. If a new article supplies a different iso prop, the previous article’s label no longer matches. The component immediately displays the new UTC fallback until its effect supplies the new local label. Render the component inside a hydrated React island if your framework defaults to static output.
Decide whose calendar the content belongs to
For a release timestamp, the viewer’s zone may be useful. For a Kathmandu conference schedule, the organizer’s calendar may be the one every reader needs. In that case format the event once for Asia/Kathmandu on the server, include the zone in the visible label, and pass the finished text to the component. Omitting the client-side formatting pass also avoids a visible label change after the page loads.
A date-only value such as 2026-01-02 calls for another decision. A birthday or invoice due date can describe a calendar day without describing any instant. Converting it to midnight UTC and then to the viewer’s zone may show the previous day. Preserve a calendar date as a date in the data model unless the domain specifies an instant.
Test the first render as well as the final label
In a browser test, run the same release page with the server configured for UTC and the browser context configured first for UTC and then for Asia/Kathmandu. Check the initial HTML in the network response. For this component it should contain 2026-01-01 20:30 UTC in both runs. After hydration, verify that the visible date matches the chosen browser locale and that the datetime attribute still identifies the release instant.
Collect console errors and uncaught page errors during navigation. A page can end up with the expected local label even after React discarded mismatched server content. Checking the final text alone would miss that regression. Playwright time zone and locale emulation
Keep static builds and cached pages in mind
On a statically generated article, the server render may have happened hours before the reader opens the page. A label such as “published five minutes ago” can therefore be stale even when the server and client agree on the time zone. Begin with an absolute publication time. If relative text matters, calculate it after hydration using the reader’s current clock and keep the absolute instant available for inspection.
A shared cache introduces a different failure mode. Suppose a server knows an authenticated reader’s preferred zone and generates a personalized timestamp. If that HTML is cached and served to someone else, the second reader could see a time intended for the first. Static UTC text works across visitors. Server-rendered localized text requires a cache policy that accounts for the data used to produce it.
Finally, check what happens with JavaScript disabled. The initial release time should still communicate a complete instant and its zone. A blank placeholder can sidestep the client mismatch while leaving a reader with no publication time at all. The UTC fallback in the example remains readable throughout the page’s lifetime.
Next steps
Keep a test instant close enough to midnight to change calendar days across your target zones. Verify the original value first if the displayed year is decades out. A seconds-versus-milliseconds error changes the instant before React ever formats it.

Written by