Advertisement
Intermediate JavaScript, Date, Time & Internationalization (Intl API)

How do you format a date for a specific locale without a library?

Short answer

Intl.DateTimeFormat lets you format dates according to locale conventions and customizable options (weekday, month style, etc.), without needing an external date library for basic formatting.

Save JavaScript mock interview
Advertisement
AModel answer
Intl.DateTimeFormat lets you format dates according to locale conventions and customizable options (weekday, month style, etc.), without needing an external date library for basic formatting.
const formatter = new Intl.DateTimeFormat('en-GB', { dateStyle: 'long' });
console.log(formatter.format(new Date())); // '8 August 2026'
Real-world example
Displaying order dates in the format users in a specific country expect (DD/MM/YYYY vs MM/DD/YYYY).
Likely follow-ups
  • How would you format just the time portion, not the date?
Related topics