I am trying to recover the date format according to the location. For example, if I use moment.locale('fr')
retrieve "DD/MM/YYYY"
or retrieve "YYYY/MM/DD"
with moment.locale('en')
.
As you can see, I use MomentJS for my date management.
Is there a MomentJS function to recover the format?
MomentJs recently announced that the library is now deprecated. This is a big deal for the javascript community who actively downloads moment almost 15 million times a week.
If you are changing locales frequently, you may want to know what locale is currently being used. This is as simple as calling moment. locale without any parameters.
You can change moment locale globally like that: import moment from 'moment'; import localization from 'moment/locale/fr'; moment. locale('fr', localization); I hope this helps you.
moment.localeData().longDateFormat('L') // "MM/DD/YYYY"
and
moment.localeData('fr').longDateFormat('L') // "DD/MM/YYYY"
seems better
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With