Course contentsShow
← Web Development
Lesson 2761 of 2,98249. Dates, Times, and Numbers on the WebFree lesson

Weekday, Era, and Calendar Options

Display weekday names, eras, and work with different calendar systems using Intl.DateTimeFormat options.

Weekday, Era, and Calendar Options

You'll learn how to display weekday names, eras (like BCE/CE), and work with non-Gregorian calendars using specialized Intl.DateTimeFormat options.

Beyond Basic Dates

You've already learned how to format dates with component-level control (day, month, year). Now we'll explore three powerful options that add cultural and historical context: weekday names, era indicators, and alternative calendar systems.

The Weekday Option

The weekday option displays the day of the week using "narrow" (M), "short" (Mon), or "long" (Monday):

const date = new Date('2025-01-15');

const narrow = new Intl.DateTimeFormat('en-US', { weekday: 'narrow' });
console.log(narrow.format(date)); // "W"

const short = new Intl.DateTimeFormat('en-US', { weekday: 'short' });
console.log(short.format(date)); // "Wed"

const long = new Intl.DateTimeFormat('en-US', { weekday: 'long' });
console.log(long.format(date)); // "Wednesday"

The Era Option

The era option shows historical periods like "BC"/"AD" or "BCE"/"CE", useful for ancient dates:

const ancientDate = new Date('-000500-03-15'); // 500 BCE

const withEra = new Intl.DateTimeFormat('en-US', {
  era: 'short',
  year: 'numeric'
});
console.log(withEra.format(ancientDate)); // "500 BC"

Working with Different Calendars

The calendar option lets you display dates in non-Gregorian systems like Islamic, Hebrew, or Chinese calendars:

const date = new Date('2025-01-15');

const islamic = new Intl.DateTimeFormat('en-US', {
  calendar: 'islamic',
  year: 'numeric',
  month: 'long',
  day: 'numeric'
});
console.log(islamic.format(date)); // "Rajab 16, 1446 AH"

These options respect locales automatically, so weekday: 'long' shows "lundi" in French and "月曜日" in Japanese.

Key Takeaway: Use weekday, era, and calendar options in Intl.DateTimeFormat to add day names, historical context, and support for diverse calendar systems—all with automatic localization.