Skip to main content
/
/
/
Formatting

Formatting

Numbers

For norwegian and swedish users, we use a space as a thousands separator and a comma as a decimal separator.

  • 1 337
  • 1 337,80

For english users, we use a comma as a thousands separator and a period as a decimal separator.

  • 1,337
  • 1,337.80

Dates

Our preferred date format depends on the current locale.

JavaScript examples

Numbers

We can use Intl.NumberFormat to format numbers:

new Intl.NumberFormat("nb-NO").format(1337); // 1 337 new Intl.NumberFormat("en-US").format(1337); // 1,337
new Intl.NumberFormat("nb-NO").format(1337); // 1 337 new Intl.NumberFormat("en-US").format(1337); // 1,337

If you want to force a set number of decimal places, you can use the minimumFractionDigits and maximumFractionDigits options:

//nb-NO new Intl.NumberFormat("nb-NO").format(1337.8, { minimumFractionDigits: 2, maximumFractionDigits: 2, }); // 1 337,80 new Intl.NumberFormat("nb-NO").format(1337.8, { minimumFractionDigits: 0, maximumFractionDigits: 0, }); // 1 338 //en-US new Intl.NumberFormat("en-US").format(1337.8, { minimumFractionDigits: 2, maximumFractionDigits: 2, }); // 1,337.80 new Intl.NumberFormat("en-US").format(1337.8, { minimumFractionDigits: 0, maximumFractionDigits: 0, }); // 1,338
//nb-NO new Intl.NumberFormat("nb-NO").format(1337.8, { minimumFractionDigits: 2, maximumFractionDigits: 2, }); // 1 337,80 new Intl.NumberFormat("nb-NO").format(1337.8, { minimumFractionDigits: 0, maximumFractionDigits: 0, }); // 1 338 //en-US new Intl.NumberFormat("en-US").format(1337.8, { minimumFractionDigits: 2, maximumFractionDigits: 2, }); // 1,337.80 new Intl.NumberFormat("en-US").format(1337.8, { minimumFractionDigits: 0, maximumFractionDigits: 0, }); // 1,338

Dates

Please note that we use en-GB since the vast majority of our "english" users are european.

new Intl.DateTimeFormat("nb-NO", { day: "2-digit", month: "2-digit", year: "numeric", }).format(new Date("2000-01-30")); // 30.01.2000 new Intl.DateTimeFormat("sv-SE").format(new Date("2000-01-30")); // 2000-01-30 new Intl.DateTimeFormat("en-GB").format(new Date("2000-01-30")); // 30/01/2000
new Intl.DateTimeFormat("nb-NO", { day: "2-digit", month: "2-digit", year: "numeric", }).format(new Date("2000-01-30")); // 30.01.2000 new Intl.DateTimeFormat("sv-SE").format(new Date("2000-01-30")); // 2000-01-30 new Intl.DateTimeFormat("en-GB").format(new Date("2000-01-30")); // 30/01/2000
React component