In this article, you will learn how internationalization works in JavaScript. Internationalization is the process of preparing software to support local language and cultural environments. It can include changing date and time format, changing metric format, language format, etc.
In this example, let's take a look at the changes in date and time formats.
var inputDate = new Date(1990, 2, 25); console.log("The date is defined as: ") console.log(inputDate) console.log("The date in United Kingdom format is: ") console.log(new Intl.DateTimeFormat('en-GB').format(inputDate)); console.log("The date in American format is: ") console.log(new Intl.DateTimeFormat('en-US').format(inputDate));
Step 1 - Define the date time value as the "inputDate" variable.
Step 2 - Use the DateTimeFormat('en-GB') function to convert datetime values specific to UK format. Display the converted value.
Step 3 - Use the DateTimeFormat('en-US') function to convert datetime values specific to the US format. Display the converted value.
var inputNumber = 2153.93; console.log("The number is defined as: ") console.log(inputNumber) console.log("The number after converting to France format is: ") console.log(new Intl.NumberFormat('it-FR').format(inputNumber)); console.log("The number after converting to American format is: ") console.log(new Intl.NumberFormat('us-US').format(inputNumber));
Step 1 - Define a numeric value for the "inputNumber" variable.
Step 2 - Use the NumberFormat('it-FR') function to convert a numeric value specific to French format. Display the converted value.
Step 3 - Use the NumberFormat('us-US') function to convert the numeric value to a specific US format. Display the converted value.
The above is the detailed content of How does internationalization work in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!