Date, Number & Currency Formatting — i18n

Store prices as numbers (70) and times as UTC (2026-12-12T06:00:00Z), then format on screen. Currency uses { style: "currency", currency: "USD" } plus…

Mrs. Sri's database used to keep the price as the text "$70.00". It looks tidy, until she wants to add up the total for 3 nights, or write the same price for an Indonesian guest. Prices, dates and times are written differently in every country, though the values are the same. The rule: store raw values, format at the edge. In Mrs. Sri's ledger, the price is written plainly as 70 and the check-in time in UTC. Every guest gets a copy rewritten in their own habits: "$70.00" for an American guest, "US$70,00" for an Indonesian one, and the same 14:00 at the homestay written as 15:00 in Tokyo. The Intl API lesson introduced the formatters; here we go into their options.

Store raw, format at the edge

// In the database and the API: numbers and UTC times, not finished text
const booking = { pricePerNight: 35, nights: 2, checkIn: '2026-12-12T06:00:00Z' };

// On screen: format with the guest's locale and the zone where it happens
const total = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' })
  .format(booking.pricePerNight * booking.nights);              // "$70.00"
const when = new Intl.DateTimeFormat('en-US', { dateStyle: 'full', timeStyle: 'short', timeZone: 'Asia/Singapore' })
  .format(new Date(booking.checkIn));                          // "Saturday, December 12, 2026 at 2:00 PM"

Currency: symbol, narrowSymbol, code, name

currencyDisplay picks how the currency is written. The room price in US dollars, plus sample amounts in other currencies (not exchange rates):

currencyDisplay en-US, USD 70 id-ID, USD 70 en-US, JPY 6500 ja-JP, JPY 6500 en-US, EGP 2150
symbol (default) $70.00 US$70,00 ¥6,500 ¥6,500 EGP 2,150.00
narrowSymbol $70.00 $70,00 ¥6,500 ¥6,500 E£2,150.00
code USD 70.00 USD 70,00 JPY 6,500 JPY 6,500 EGP 2,150.00
name 70.00 US dollars 70,00 Dolar Amerika Serikat 6,500 Japanese yen 6,500円 2,150.00 Egyptian pounds

Compact notation and units

new Intl.NumberFormat('en-US', { notation: 'compact' }).format(1200000);                           // "1.2M"
new Intl.NumberFormat('en-US', { notation: 'compact', compactDisplay: 'long' }).format(1200000);   // "1.2 million"
new Intl.NumberFormat('en-US', { style: 'unit', unit: 'kilometer', unitDisplay: 'long' }).format(26); // "26 kilometers"
new Intl.NumberFormat('en-US', { style: 'unit', unit: 'celsius' }).format(12);                     // "12°C"

Dates: dateStyle or one field at a time

Options en-US id-ID ja-JP ar-EG
dateStyle: 'short' 12/12/26 12/12/26 2026/12/12 ١٢/١٢/٢٠٢٦
dateStyle: 'medium' Dec 12, 2026 12 Des 2026 2026/12/12 ١٢/١٢/٢٠٢٦
dateStyle: 'long' December 12, 2026 12 Desember 2026 2026年12月12日 ١٢ ديسمبر ٢٠٢٦
{ weekday: 'short', day: 'numeric', month: 'short' } Sat, Dec 12 Sab, 12 Des 12月12日(土) السبت، ١٢ ديسمبر

Ranges and relative time

const checkIn = new Date('2026-12-12T06:00:00Z');   // Saturday 14:00 at the homestay
const checkOut = new Date('2026-12-14T04:00:00Z');  // Monday 12:00 at the homestay
new Intl.DateTimeFormat('en-US', { day: 'numeric', month: 'short', timeZone: 'Asia/Singapore' }).formatRange(checkIn, checkOut);
// "Dec 12\u2009\u2013\u200914" in Node and Chromium 147, "Dec 12 \u2013 14" in Chromium 156, Firefox and Safari   (\u2013 is the en dash)
// id-ID: "12\u201314 Des"
// ja-JP: "12/12~12/14", Firefox "12月12日~14日"; ar-EG: "١٢\u2013١٤ ديسمبر"

const rtf = new Intl.RelativeTimeFormat('en-US', { numeric: 'auto' });
rtf.format(3, 'day');   // "in 3 days"
rtf.format(1, 'day');   // "tomorrow"

One instant, three wall clocks

Mrs. Sri's check-in falls at 2026-12-12T06:00:00Z, 14:00 at the homestay (Asia/Singapore). Before you look at the results, guess: a guest in Cairo who formats it with timeZone: 'Africa/Cairo' sees what time? And is it the same hour if the date is 12 July?

const fmt = (zone) => new Intl.DateTimeFormat('en-US', { weekday: 'short', day: 'numeric', month: 'short', hour: 'numeric', minute: '2-digit', timeZoneName: 'short', timeZone: zone }).format(checkIn);
fmt('Asia/Singapore');  // "Sat, Dec 12, 2:00 PM GMT+8"
fmt('Asia/Tokyo');      // "Sat, Dec 12, 3:00 PM GMT+9"   (ja-JP writes "JST")
fmt('Africa/Cairo');    // "Sat, Dec 12, 8:00 AM GMT+2"

Cairo shows 8:00 AM, because in December Egypt is on UTC+2. Egypt uses summer time, so for 12 July the offset is GMT+03:00 and the hour is 9:00 AM. So never store "UTC+2" as a zone; store the IANA name (Africa/Cairo) and let Intl work it out. "SGT" isn't a zone name either: timeZone: 'SGT' throws a RangeError. For a check-in schedule, write the time in the homestay's zone (Asia/Singapore); the time in the guest's zone may be added as a note.

📌 How the engines differ, measured

Measured in Chromium 147, Firefox 146, WebKit 26.4 and Node 22.22.1. Anything not in this table was the same in all four.

Measured Chromium 147 Firefox 146 WebKit 26.4 Node 22.22.1
Default IDR decimals 2 2 2 0
IDR 349999.5 with only minimumFractionDigits: 0 Rp 349.999,5 Rp 349.999,5 Rp349.999,5 Rp 350.000
JPY symbol in ja-JP ¥ ¥ ¥ ¥
Spaces in an en-US range U+2009 plain spaces plain spaces U+2009
ja-JP range 12/12~12/14 12月12日~14日 12/12~12/14 12/12~12/14
weekday: 'short' in ar-EG السبت السبت سبت السبت
TypeError message for dateStyle plus weekday Invalid option : option can't set option weekday when dateStyle is used dateStyle and timeStyle may not be used with other DateTimeFormat options Invalid option : option
unit: 'day', long, ja-JP 2 日 2 日 2日 2 日
weekday plus hour in en-US Sat, Dec 12, 2:00 PM Sat, Dec 12, 2:00 PM Sat, Dec 12 at 2:00 PM Sat, Dec 12, 2:00 PM

We measured again on 29 October 2026 with Chromium 156.0.8078.4 and Firefox 148.0.2 from Playwright. Firefox 148 matches the Firefox 146 column exactly. Chromium 156 differs in three rows: the default IDR decimals are now 0, 349999.5 becomes "Rp 350.000", and an en-US range uses plain spaces.

⚠️ Why is the price or the time off?

TL;DR: Store prices as numbers (70) and times as UTC (2026-12-12T06:00:00Z), then format on screen. Currency uses { style: "currency", currency: "USD" } plus currencyDisplay (symbol "$70.00", or "US$70,00" in id-ID, narrowSymbol "$", code "USD", name "US dollars"). A currency whose decimals differ by engine needs maximumFractionDigits: 0: the rupiah's default decimals are 2 in Firefox, Safari and Chrome 147 but 0 in Node 22 and Chrome 156. The en-US locale writes 1000000 as "1,000,000". Compact notation ("1.2M", "1,2 jt", "120万") rounds, so it's not for prices. style: 'unit' for km, °C and days. Dates use dateStyle or fields, never both. formatRange writes "Dec 12 to 14" with the U+2013 dash, RelativeTimeFormat writes "in 3 days". The same check-in is 14:00 in Asia/Singapore, 15:00 in Asia/Tokyo and 08:00 in Africa/Cairo (09:00 in July); store the IANA zone name, not an offset.

⚡ Store raw, format at the edge

Write:

// In the database and the API: numbers and UTC times, not finished text
const booking = { pricePerNight: 35, nights: 2, checkIn: '2026-12-12T06:00:00Z' };

Meaning: The price is stored as a number, time as a UTC instant. The text "$70.00" can't be added up and can't be rewritten for another locale.

⚡ Dollars in the en-US locale

Write:

const total = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' })
  .format(booking.pricePerNight * booking.nights);              // "$70.00"
Guess first: how does the en-US locale write 1000000?

1,000,000, with a comma as the thousands separator. An Indonesian guest gets US$70,00, with a comma before the cents.

Meaning: The locale decides the thousands and decimal separators. The currency decides the decimals: 2 for US dollars, in every engine.

⚡ One instant, three wall clocks

Meaning: The check-in 2026-12-12T06:00:00Z is 14:00 in Asia/Singapore, 15:00 in Asia/Tokyo and 08:00 in Africa/Cairo (09:00 in July, because of summer time). So store the IANA zone name, not an offset. timeZone: 'SGT' even throws a RangeError.

What you will learn