#1366·luxon

`toFormat` with unknown locale defaults to system locale instead of Luxon settings `defaultLocale`

Author: jaydensericCreated Jan 19, 2023Updated May 19, 2026
Labelsissue: enhancementup for grabsv4

Describe the bug A clear and concise description of what the bug is.

Calling the Luxon DateTime instance method toFormat while specifying an unknown locale for the locale option causes formatting to default to the system locale instead of Luxon settings defaultLocale.

To Reproduce Please share a minimal code example that triggers the problem:

In demo.mjs:

javascript
import { DateTime, Settings } from "luxon";

// System default locale is `en-AU`.
Settings.defaultLocale = "en-US";

const dateTime = DateTime.fromJSDate(new Date("2022-12-01"));

// Logs `1 December 2022 at 11:00 GMT+11` (`en-AU` formatting) instead of the
// expected `December 1, 2022 at 11:00 AM GMT+11` (`en-US` formatting).
console.log(dateTime.toFormat("fff", { locale: "zz" }));

Run:

bash
node demo.mjs

Actual vs Expected behavior A clear and concise description of what you expected to happen.

Logs 1 December 2022 at 11:00 GMT+11 (en-AU formatting) instead of the expected December 1, 2022 at 11:00 AM GMT+11 (en-US formatting).

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Node.js v19.4.0
  • Luxon version: v3.2.1
  • Your timezone: N/A

Additional context Add any other context about the problem here.

N/A.