Skip to content

Instantly share code, notes, and snippets.

@andreciornavei
Created May 5, 2022 10:16
Show Gist options
  • Select an option

  • Save andreciornavei/9d8b4af08155620833ff9f8388deacc4 to your computer and use it in GitHub Desktop.

Select an option

Save andreciornavei/9d8b4af08155620833ff9f8388deacc4 to your computer and use it in GitHub Desktop.
Formatting with Intl on Javascript
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