Format dates without a library

Intl.DateTimeFormat does most of what you used moment or date-fns for.

SNP 061 #351 Filed js

javascript
const date = new Date('2026-02-05T07:30:00Z')

new Intl.DateTimeFormat('en-US', { dateStyle: 'long' }).format(date)
// February 5, 2026

new Intl.DateTimeFormat('en-GB', { dateStyle: 'medium' }).format(date)
// 5 Feb 2026

new Intl.DateTimeFormat('hu-HU').format(date)
// 2026. 02. 05.

Pick the parts yourself with the year, month, day, weekday and hour options, and pass timeZone: 'UTC' when you want the same output on every machine (like a static site build).

Relative times work too:

javascript
new Intl.RelativeTimeFormat('en', { numeric: 'auto' }).format(-3, 'day')
// 3 days ago