JavaScript Calendar Locale: Internationalize With the Intl API
By SimpleCalendarJS Team
Pass a BCP 47 locale such as 'de-DE' to Intl.DateTimeFormat for month, weekday and time labels. Read the first day of the week from Intl.Locale's getWeekInfo() and the 12/24-hour preference from resolvedOptions().hourCycle. Then pass those values to your calendar instead of hard-coding English and Sunday-first weeks.
A calendar that works for a team in Chicago can feel wrong in Berlin, Cairo or Tokyo. The weekday names are in English, weeks start on the wrong day, and 3 PM shows up where people expect 15:00. To get the JavaScript calendar locale right, you don't need a big i18n library. The built-in Intl API gives you everything a calendar needs: localized labels, week start days, hour cycles, range formatting and text direction.
This guide shows each piece with plain JavaScript you can paste into a console. Then it connects them to a calendar component.
What a Calendar Needs From a Locale
Translating the toolbar buttons is the easy part of localizing a calendar. The harder parts are the small conventions that users notice when they're wrong:
| Calendar detail | Example difference | Intl API |
|---|---|---|
| Month and year title | "December 2026" vs "Dezember 2026" | Intl.DateTimeFormat with month / year |
| Weekday headers | "Mon" vs "lun." vs "月" | Intl.DateTimeFormat with weekday |
| First day of the week | Sunday (US), Monday (UK, Germany), Saturday (some Arabic regions) | Intl.Locale.prototype.getWeekInfo() |
| Weekend days | Saturday–Sunday vs Friday–Saturday | getWeekInfo().weekend |
| 12- or 24-hour time | "2:00 PM" vs "14:00" | resolvedOptions().hourCycle |
| Event time ranges | "10:00 – 11:00 AM" | Intl.DateTimeFormat.prototype.formatRange() |
| Relative labels in list views | "tomorrow", "in 3 days" | Intl.RelativeTimeFormat |
| Text direction | left-to-right vs right-to-left | Intl.Locale.prototype.getTextInfo() |
All of these take a BCP 47 language tag like en-US, fr-CA or ar-EG. The region part matters. en-US and en-GB use the same language but have different week starts and date orders.
Formatting Calendar Labels With Intl.DateTimeFormat
Intl.DateTimeFormat turns a Date into a localized string. You choose which parts to show, and the locale decides their order, spelling and punctuation.
Month titles and weekday headers
const locale = 'de-DE'; // Toolbar title: month + year const titleFmt = new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }); console.log(titleFmt.format(new Date(2026, 11, 1))); // "Dezember 2026" // Weekday headers, starting from a given day (0 = Sunday ... 6 = Saturday) function weekdayHeaders(locale, weekStartsOn = 0, format = 'short') { const fmt = new Intl.DateTimeFormat(locale, { weekday: format }); // 1 November 2026 is a Sunday, so day i of that week has getDay() === i return Array.from({ length: 7 }, (_, i) => fmt.format(new Date(2026, 10, 1 + ((weekStartsOn + i) % 7))) ); } console.log(weekdayHeaders('en-US', 0)); // ["Sun", "Mon", "Tue", ...] console.log(weekdayHeaders('fr-FR', 1)); // Monday-first French headers
The weekday option accepts 'long', 'short' or 'narrow'. Be careful with 'narrow': MDN points out that it can be ambiguous, because Tuesday and Thursday are both "T" in en-US. In a compact mobile month grid that may be fine. In a week view header, use 'short'.
Reuse formatters instead of calling toLocaleDateString
A month grid formats 35–42 day cells, plus headers and event times, on every render. MDN notes that each toLocaleDateString() call searches a large database of localization strings, and recommends creating an Intl.DateTimeFormat once and calling format() on it repeatedly. A small cache keyed by locale and options is enough:
const formatterCache = new Map(); function getFormatter(locale, options) { const key = locale + JSON.stringify(options); if (!formatterCache.has(key)) { formatterCache.set(key, new Intl.DateTimeFormat(locale, options)); } return formatterCache.get(key); } const dayNumber = getFormatter('ja-JP', { day: 'numeric' });
12-hour vs 24-hour time
Don't guess the hour cycle from the language. Ask the runtime. Create a formatter that includes an hour, then read hourCycle from resolvedOptions():
function prefers24Hour(locale) { const { hourCycle } = new Intl.DateTimeFormat(locale, { hour: 'numeric' }).resolvedOptions(); return hourCycle === 'h23' || hourCycle === 'h24'; } prefers24Hour('en-US'); // false prefers24Hour('de-DE'); // true
The hour option matters. According to MDN, hourCycle and hour12 only appear in the resolved options when the formatter includes an hour component. Without one, hourCycle is undefined and the check always returns false.
To override the locale default (for example, a user setting that forces 24-hour time), there are three knobs. MDN documents how they interact:
- the
hourCycleoption ('h11','h12','h23','h24') - the
hcextension in the locale tag, e.g.'en-US-u-hc-h23' - the
hour12boolean, which overrides both of the others
Need a calendar in your app?
SimpleCalendarJS: ~14 KB gzipped, zero dependencies, works in any framework. Free for personal use.
Finding the First Day of the Week in JavaScript
The first day of the week is the setting most often hard-coded and most often wrong. Since 2026, the platform can tell you directly. Intl.Locale.prototype.getWeekInfo() returns CLDR week data for a locale:
new Intl.Locale('en-US').getWeekInfo(); // { firstDay: 7, weekend: [6, 7] } new Intl.Locale('en-GB').getWeekInfo(); // { firstDay: 1, weekend: [6, 7] } new Intl.Locale('he').getWeekInfo(); // { firstDay: 7, weekend: [5, 6] }
Those outputs come from MDN's examples. Note the numbering: 1 is Monday and 7 is Sunday (ISO style). Date.prototype.getDay() uses 0 for Sunday. Mix them up and your grid shifts by a day.
Browser support and a safe fallback
getWeekInfo() is part of the "Intl.Locale info" feature, which became Baseline Newly Available on 21 July 2026 when Firefox 153 shipped it. Chrome and Edge have had it since version 130 (October 2024), and Safari since 17 (September 2023). Some older engines exposed it as an accessor property named weekInfo instead of a method, so feature-detect both:
// Returns 0 (Sunday) ... 6 (Saturday), matching Date.prototype.getDay() function firstDayOfWeek(tag, fallback = 1) { const locale = new Intl.Locale(tag); const info = typeof locale.getWeekInfo === 'function' ? locale.getWeekInfo() : locale.weekInfo; if (!info || !info.firstDay) return fallback; return info.firstDay % 7; // 7 (Sunday) -> 0, 1 (Monday) -> 1, 6 (Saturday) -> 6 } firstDayOfWeek('en-US'); // 0 firstDayOfWeek('fr-FR'); // 1
The fallback here is Monday, the ISO 8601 default. If your users are mostly in the US, use 0 instead. Either way, let users override it in their settings, because personal preference often differs from the regional default.
You can use weekend the same way to shade weekend columns in a week view. Convert each value with % 7 before comparing it with getDay(). The week view guide covers the layout side.
Region overrides
Users can set a language from one place and regional conventions from another. The rg extension expresses this, and getWeekInfo() respects it. MDN's example shows 'en-US-u-rg-gbzzzz' returning a Monday first day: US English with British week conventions. If your app stores separate language and region settings, build the tag this way rather than picking one.
Formatting Ranges and Relative Dates
Event popovers, week titles and list views all show ranges or relative dates. Building those by joining strings ("Jan 10" + " - " + "Jan 20, 1906") gives the wrong word order or punctuation in many locales.
formatRange for event times and week titles
formatRange() has been available in all major browsers since August 2021. It collapses the parts that two dates share:
const fmt = new Intl.DateTimeFormat('en', { year: 'numeric', month: 'short', day: 'numeric' }); fmt.formatRange(new Date(1906, 0, 10), new Date(1906, 0, 20)); // "Jan 10 – 20, 1906" const timeFmt = new Intl.DateTimeFormat('en', { year: '2-digit', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', }); timeFmt.formatRange(new Date(1906, 0, 10, 10, 0), new Date(1906, 0, 10, 11, 0)); // "1/10/06, 10:00 – 11:00 AM"
The second example is the event popover case: a same-day event shows the date once and only the time range. If both dates are equal at the precision you're showing, it returns a single date. That gives you all-day labels without extra logic.
RelativeTimeFormat for list and agenda views
An upcoming-events list reads better with "Today", "Tomorrow" and "In 3 days" headings. Intl.RelativeTimeFormat with numeric: 'auto' uses words like "yesterday" and "tomorrow" where the language has them. The default, 'always', always shows a number ("in 1 day").
const rtf = new Intl.RelativeTimeFormat('es', { numeric: 'auto' }); function dayLabel(date, today = new Date()) { const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate()); // Math.round absorbs the 23- or 25-hour days around DST changes const diff = Math.round((startOfDay(date) - startOfDay(today)) / 86_400_000); return rtf.format(diff, 'day'); } dayLabel(new Date(Date.now() + 2 * 86_400_000)); // "pasado mañana"
Choosing the Locale and Handling Right-to-Left Text
Read the user's preference, then let them change it
navigator.languages is an array of the user's preferred languages, most preferred first. navigator.language is its first entry. You can pass the whole array to any Intl constructor. The runtime uses the first locale it supports, which is better than passing only the top choice:
const fmt = new Intl.DateTimeFormat(navigator.languages, { dateStyle: 'medium' }); console.log(fmt.resolvedOptions().locale); // the locale actually used
resolvedOptions().locale shows the result of that negotiation. If you request an unsupported tag, you get a fallback. MDN's example resolves 'de-XX' to 'de'. Use the resolved value when you pass a single locale string to other code.
Two practical notes from MDN. First, a languagechange event fires on window when the user changes their language list, so you can re-render. Second, for privacy reasons the list may be incomplete: Safari always shortens it, and Chrome's incognito mode reports only one language. Browser settings are a starting point. A saved user preference should win.
Text direction
Intl.Locale.prototype.getTextInfo() returns { direction: 'rtl' } or { direction: 'ltr' }, based on the locale's script. It has the same Baseline 2026 status and the same old accessor form (textInfo) as getWeekInfo():
function textDirection(tag) { const locale = new Intl.Locale(tag); const info = typeof locale.getTextInfo === 'function' ? locale.getTextInfo() : locale.textInfo; return info?.direction ?? 'ltr'; } document.documentElement.dir = textDirection('ar-SA'); // "rtl"
Pitfalls That Break Localized Calendars
- Date-only strings are UTC. MDN documents that
'2026-12-14'is parsed as UTC midnight, while'2026-12-14T00:00'is parsed as local time. West of UTC, a date-only event lands on the previous day. Create dates withnew Date(2026, 11, 14)or local date-time strings. - Locale is not time zone. A
fr-FRlocale doesn't mean Paris time.Intl.DateTimeFormathas a separatetimeZoneoption, and by default it uses the runtime's time zone. Store events in UTC and convert them on purpose. The REST API events guide covers this when loading data. - Formatted strings are for display only. Output can differ between browsers and engine versions. Never parse a formatted date back into a
Date, and don't snapshot-test exact strings. dateStyleandtimeStylecan't be mixed with component options.{ dateStyle: 'medium', weekday: 'long' }throws aTypeError. Use one style or the other.
A Locale-Aware JavaScript Calendar With SimpleCalendarJS
Building a localized month, week and day grid yourself means using everything above in every cell. SimpleCalendarJS uses Intl.DateTimeFormat internally for its date labels, so it accepts any BCP 47 locale through its locale option. It also includes translated toolbar labels for 34 locales, including en-US, en-GB, de-DE, fr-FR, es-MX, pt-BR, ja-JP, zh-CN, ar-SA and he-IL. Two things it doesn't detect for you are the first day of the week and the hour cycle. You pass those as weekStartsOn and use24Hour, which is where the helpers from this post come in.
The example below detects the user's locale, derives the week start and hour cycle, and rebuilds the calendar when the user picks another language. There's no method to change the locale on a live instance, so the switcher calls destroy() and creates a new calendar. It keeps the current view and date through onViewChange and onNavigate.
<label> Language <select id="locale-select"> <option value="en-US">English (US)</option> <option value="en-GB">English (UK)</option> <option value="de-DE">Deutsch</option> <option value="fr-FR">Français</option> <option value="pt-BR">Português (Brasil)</option> <option value="ja-JP">日本語</option> </select> </label> <div id="calendar" style="height: 600px"></div>
import SimpleCalendarJs from 'simple-calendar-js'; import 'simple-calendar-js/dist/simple-calendar-js.min.css'; const events = [ { id: 1, title: 'Sprint review', start: new Date(2026, 11, 8, 14, 0), end: new Date(2026, 11, 8, 15, 0), color: '#4f46e5' }, { id: 2, title: 'Design sync', start: '2026-12-10T09:30', end: '2026-12-10T10:15', color: '#0d9488' }, { id: 3, title: 'Release', start: '2026-12-17T16:00', end: '2026-12-17T17:00', color: '#b45309' }, ]; // --- Intl helpers --- function prefers24Hour(locale) { const { hourCycle } = new Intl.DateTimeFormat(locale, { hour: 'numeric' }).resolvedOptions(); return hourCycle === 'h23' || hourCycle === 'h24'; } function firstDayOfWeek(tag, fallback = 1) { const locale = new Intl.Locale(tag); const info = typeof locale.getWeekInfo === 'function' ? locale.getWeekInfo() : locale.weekInfo; return info && info.firstDay ? info.firstDay % 7 : fallback; } function detectLocale(supported) { const preferred = navigator.languages || [navigator.language]; return ( preferred.find((tag) => supported.includes(tag)) || supported.find((tag) => tag.split('-')[0] === preferred[0].split('-')[0]) || 'en-US' ); } // --- Calendar setup --- const select = document.getElementById('locale-select'); const supported = [...select.options].map((o) => o.value); let calendar = null; let currentView = 'month'; let currentDate = new Date(); function createCalendar(locale) { calendar?.destroy(); // The documented weekStartsOn values are 0 (Sunday) and 1 (Monday) const weekStartsOn = firstDayOfWeek(locale) === 0 ? 0 : 1; calendar = new SimpleCalendarJs('#calendar', { locale, weekStartsOn, use24Hour: prefers24Hour(locale), defaultView: currentView, defaultDate: currentDate, enabledViews: ['month', 'week', 'day', 'list'], fetchEvents: async () => events, onViewChange: (view) => { currentView = view; }, onNavigate: (rangeStart, rangeEnd) => { // Middle of the visible range, so month grids don't snap to the previous month currentDate = new Date((rangeStart.getTime() + rangeEnd.getTime()) / 2); }, onEventClick: (event) => { const fmt = new Intl.DateTimeFormat(locale, { dateStyle: 'medium', timeStyle: 'short' }); alert(`${event.title}\n${fmt.formatRange(new Date(event.start), new Date(event.end))}`); }, }); document.documentElement.lang = locale; } const initial = detectLocale(supported); select.value = initial; createCalendar(initial); select.addEventListener('change', () => createCalendar(select.value));
A few notes on this code:
weekStartsOnis limited to Sunday or Monday here because those are the two documented values. For a region whose week starts on Saturday, this maps to Monday. If you need Saturday-first weeks, check the docs before passing6.- Events come from
fetchEvents. Here it returns a fixed array. In a real app, call your API there, then callcalendar.refresh()after you add, change or remove events. - The inline
height: 600pxgives the month view a fixed height with "+N more" overflow. It has to be an inline style. A height from a stylesheet or utility class doesn't count. - Time zones are your job. SimpleCalendarJS shows dates in the browser's local time and has no time zone option, so convert event times before returning them.
There are also limits. SimpleCalendarJS has no recurring-event engine, no resource or timeline views, and no TypeScript definitions. If your localized app needs a multi-resource scheduler, see the JavaScript scheduler comparison. If you need a localized date picker rather than a full calendar, the same locale, weekStartsOn and use24Hour options work in mode: 'date-picker' and mode: 'range-picker'. The date range picker guide covers that setup. You can try different locales in the sandbox.
On licensing: SimpleCalendarJS is free for personal, educational and open source projects. Commercial use, including client sites, SaaS and internal company tools, requires a license per project. See pricing.
Need a calendar in your app?
SimpleCalendarJS: ~14 KB gzipped, zero dependencies, works in any framework. Free for personal use.
Sources & Further Reading
- Intl.DateTimeFormat() constructor — MDN
- Intl.DateTimeFormat.prototype.resolvedOptions() — MDN
- Intl.DateTimeFormat.prototype.formatRange() — MDN
- Intl.Locale.prototype.getWeekInfo() — MDN
- Intl.Locale.prototype.getTextInfo() — MDN
- Intl.Locale info — Web Features Explorer
- Intl.RelativeTimeFormat — MDN
- Navigator: languages property — MDN
- Date.parse() — MDN
- Date.prototype.toLocaleDateString() — MDN
Image Credits
- Cover: A world map on the wall — Pexels
Image free to use under the Pexels License.
Frequently Asked Questions
How do I force 24-hour time for a locale that normally uses 12-hour time?
Pass hourCycle: 'h23' in the Intl.DateTimeFormat options, or add the hc extension to the locale tag, as in 'en-US-u-hc-h23'. If both are set, the options value wins. The hour12 option overrides both of them, and hour12: false always resolves to h23.
How do I show dates in a non-Gregorian calendar like Persian or Islamic?
Use the calendar option of Intl.DateTimeFormat (for example calendar: 'persian') or the ca extension in the locale tag ('fa-IR-u-ca-persian'). Intl.supportedValuesOf('calendar') lists the calendars the runtime supports. Most calendar components still lay out a Gregorian grid, so this mainly changes labels.
How do I display native digits, such as Arabic-Indic numerals, in dates?
Set the numberingSystem option of Intl.DateTimeFormat (for example numberingSystem: 'arab') or add the nu extension to the locale tag ('ar-u-nu-arab'). Each locale has its own default numbering system. resolvedOptions().numberingSystem tells you which one a formatter actually uses.
Should I reuse Intl.DateTimeFormat objects or call toLocaleDateString?
Reuse them. MDN notes that each toLocaleDateString call searches a large database of localization strings. When you format many dates with the same arguments, such as every cell of a month grid, create one Intl.DateTimeFormat and call its format() method repeatedly.
Does the Intl API give me ISO week numbers?
No. Intl has no week-number formatter, and the minimalDays field of getWeekInfo() has been removed from the spec because users expect ISO rules regardless of locale. To show week numbers, compute the ISO 8601 week yourself: weeks start on Monday, and week 1 contains the year's first Thursday.
Why does the same date format differently in Chrome, Firefox and Safari?
Each engine ships its own version of the Unicode CLDR locale data, and the defaults change between releases. Don't snapshot-test exact formatted strings and don't parse them back into dates. Check behavior at runtime with resolvedOptions() and use formatToParts() when you need individual pieces.
Add a calendar to your app today
Free for personal projects. $49/year or $199 lifetime per commercial project.



