Created
May 5, 2022 10:16
-
-
Save andreciornavei/9d8b4af08155620833ff9f8388deacc4 to your computer and use it in GitHub Desktop.
Formatting with Intl on Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const language = "pt-BR" | |
| // formatting lists | |
| const vehicles = ["Car", "Bike", "Airplan"] | |
| new Intl.ListFormat(language, { style: "long", type: "conjunction" }).format(vehicles) | |
| // formatting units | |
| const kmTraveled = 10000 | |
| new Intl.NumberFormat(language, { style: "unit", unit: "kilometer" }).format(kmTraveled) | |
| // formatting dates | |
| const date = new Date() | |
| new Intl.DateTimeFormat(language, { month: "long", day: "2-digit", year: "numeric" }).format(date) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment