← All writing
TIL

TIL: format publication dates consistently

A tiny detail that prevents a date from changing across build environments.

When a date-only value is parsed as UTC, formatting it in a local timezone can display the previous day.

Set the timezone explicitly

For publication dates, UTC formatting keeps the output stable across development and deployment machines.

new Intl.DateTimeFormat('en', { timeZone: 'UTC', dateStyle: 'medium' }).format(date);