Formatting
Go to top
Numbers
For norwegian, swedish, and finnish users, we use a space as a thousands separator and a comma as a decimal separator.
- 1 337
- 1 337,80
For danish users, we use a period 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.
- For Norwegian users, we use the norwegian
format
30.01.2000. - For Swedish users, we use ISO 8601
2000-01-30. - For Danish and Finnish users, we use the same dot-separated
30.01.2000format as Norwegian. - For all other users, we use the british
format
30/01/2000.
JavaScript examples
Numbers
We can use
Intl.NumberFormat
to format numbers:
JavaScript
new Intl.NumberFormat("nb-NO").format(1337); // 1 337
new Intl.NumberFormat("da-DK").format(1337); // 1.337
new Intl.NumberFormat("en-US").format(1337); // 1,337If you want to force a set number of decimal places, you can use the
minimumFractionDigits and maximumFractionDigits options:
JavaScript
//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
//da-DK
new Intl.NumberFormat("da-DK").format(1337.8, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}); // 1.337,80
new Intl.NumberFormat("da-DK").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,338Dates
Please note that we use en-GB since the vast majority of our "english"
users are european.
JavaScript
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("da-DK", {
day: "2-digit",
month: "2-digit",
year: "numeric",
}).format(new Date("2000-01-30")); // 30.01.2000
new Intl.DateTimeFormat("fi-FI", {
day: "2-digit",
month: "2-digit",
year: "numeric",
}).format(new Date("2000-01-30")); // 30.01.2000
new Intl.DateTimeFormat("en-GB").format(new Date("2000-01-30")); // 30/01/2000