JS Coding Questions Logo
JS Coding Questions
#234💼 Interview💻 Code

How do you perform language specific date and time formatting

Advertisement

728x90

You can use the Intl.DateTimeFormat object which is a constructor for objects that enable language-sensitive date and time formatting. Let's see this behavior with an example,

javascript
1var date = new Date(Date.UTC(2019, 07, 07, 3, 0, 0));
2
3console.log(new Intl.DateTimeFormat("en-GB").format(date)); // 07/08/2019
4
5console.log(new Intl.DateTimeFormat("en-AU").format(date)); // 07/08/2019

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 63

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
234of476
How do you perform language specific date and time formatting | JSCodingQuestions.com