Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-intl - FormattedDate - DD/MM/YYYY instead of MM/DD/YYYY (for en-us!)

I have an application with react-intl injected. Its bilingual - in English and in Polish so i represent dates with . When I represent let's say 12 April 2005 its:

  • 12.04.2005 in Polish

  • 04/12/2005 in English

It confuses everyone as people think about the second date as 4th December. Can i somehow format dates so in English it would be DD/MM/YYYY ?

like image 520
jake-ferguson Avatar asked Jan 18 '26 09:01

jake-ferguson


1 Answers

So, if the locale of your application is working fine, you can just use the FormattedDate component from react-intland it will display the date in the current format.

Assuming that the locale is in place, you'd only have to use it like this:

<FormattedDate
    value="12.04.2005"
    day="2-digit"
    month="2-digit"
    year="numeric"
/>

The FormattedDate component will use the locale of the application to format it to english or polish (or any other locale you set). Here is the reference in the doc

like image 156
sergioviniciuss Avatar answered Jan 20 '26 00:01

sergioviniciuss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!