Skip to content

Instantly share code, notes, and snippets.

View alinkedd's full-sized avatar
:octocat:
Looking for remote projects

Alina Listunova alinkedd

:octocat:
Looking for remote projects
View GitHub Profile
@alinkedd
alinkedd / format-plain-month-day-range.js
Created January 8, 2026 01:11
Hide the year in a date range when the years differ, while still using Intl.DateTimeFormat.formatRange
const formatter = new Intl.DateTimeFormat('en', {
day: 'numeric',
month: 'long',
})
const startDate = new Date(2025,11,24);
const endDate = new Date(2026,0,4);
// If the year is different, it is always shown:
console.log(formatter.formatRange(startDate, endDate));