How to get localized date?
See original GitHub issueHello, I’ve got a question.
Is there any way to get a date (year, month,day) in localized format without loading
a locale first: require('dayjs/locale/de'), etc.?
var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
// US English uses month-day-year order
console.log(new Intl.DateTimeFormat('en-US').format(date));
// → "12/19/2012"
// British English uses day-month-year order
console.log(new Intl.DateTimeFormat('en-GB').format(date));
// → "19/12/2012"
Issue Analytics
- State:
- Created 2 years ago
- Comments:13
Top Results From Across the Web
Date and time localization - Lokalise Blog
In this article, we are going to discuss some of the methods that make the date and time localization process easier.
Read more >How do I get localized date pattern string? - java
You can use DateTimeFormatterBuilder in Java 8. Following example returns localized date only pattern e.g. "d.M.yyyy" ...
Read more >Date.prototype.toLocaleDateString() - JavaScript | MDN
The toLocaleDateString() method returns a string with a language-sensitive representation of the date portion of the specified date in the ...
Read more >Get Date and Time in User's locale format in JavaScript
Use the toLocaleString() method to get a date and time in the user's locale format, e.g. date.toLocaleString() .
Read more >Java 8 Date - LocalDate, LocalDateTime, Instant - DigitalOcean
LocalDate is an immutable class that represents Date with default format of yyyy-MM-dd. We can use now() method to get the current date....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

No, you can load a new locale by loading a module dynamically.
Something like this: https://webpack.js.org/api/module-methods/#dynamic-expressions-in-import.
I don’t know how the final result will look like, as I haven’t implemented this myself
You have to import a specific locale first:
These are all the available locales: https://github.com/iamkun/dayjs/tree/dev/src/locale