Moment: Get pattern based on locale

Created on 24 Apr 2019  ·  3Comments  ·  Source: moment/moment

what i would like is to get for example the value D.M.YYYY based on the locale. (in this example, german).

so if locale is english, the output would be M/D/YYYY

there is no pattern property, unless i missed it?

Most helpful comment

To get the Local Format

Use:

moment.localeData().longDateFormat('L')

This function will return local date format.

That's it.
_So easy!!!!_

All 3 comments

To get the Local Format

Use:

moment.localeData().longDateFormat('L')

This function will return local date format.

That's it.
_So easy!!!!_

i made a mistake. i did not use the local js library. my bad. thank you

what i want to do is actually use the isValid() feature.

Now, if I do this

moment('2', 'M/D/YYYY').isValid()

how come it returns true?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tanepiper picture tanepiper  ·  3Comments

alvarotrigo picture alvarotrigo  ·  3Comments

ninigix picture ninigix  ·  3Comments

M-Zuber picture M-Zuber  ·  3Comments

nikocraft picture nikocraft  ·  3Comments