Open m-zzz opened 3 years ago
I believe the DayJS defaults to en-us when you don't specify any or set locale as 'en-us' without importing it. I think en locale is the same as en-gb
But yeah it's confusing
A bit frustrating since en-gb
and en-us
aren't the same... Eg. in US dates are formatted like MM/DD/YYYY, however in GB it's formatted like this: DD/MM/YYYY
It's simple really. If you need to use one or the other, just call the locale method with it.
dayjs().locale('en-us').format('ll'); // Dec 21, 2021
dayjs().locale('en-gb').format('ll'); // 21 Dec 2021
Given that en-US is the default, you won't be importing it. You can learn more about Day.js locales here.
That that's not working... When I set my locale to en-gb
the date format is still MM/DD/YYYY
when it should be DD/MM/YYYY
Nevermind, I got it sorted after readying your blog post, thank you!
When using the localeData plugin, except if you use (load) 'en-gb', you don't have the requested functions (methods), for example globalLocaleData.longDateFormat('L')
or globalLocaleData.weekdaysMin()
and so on.
Describe the bug Is the locale "en" the same as "en-us"? I see here https://unpkg.com/dayjs@1.10.5/locale.json just "es-us" locale for United States.
Expected behavior Maybe it make sense to add also "en-us" locale?
Information