I'm making a calendar in Portuguese on ReactJS.
Despite being something simple, I'm not able to change my library date "moment.js" to be in the portuguese language (brazil).
Already tried code:
<strong>{moment(currentDate).locale('pt-br').format('LLLL')}</strong>
But I don't work, it keeps bringing the date in English.
1: 
This is the date format code:
const [currentDate, setCurrentDate] = useState(new Date())
<Col>
<strong>{moment(currentDate).format('LLLL')}</strong>
</Col>
How do I make the date stay in Portuguese(Brazil)?
I just decided to import the location:
import 'moment/locale/pt-br'
and add code:
moment.locale('pt-br')
I have tried to use 'pt-br' like this:
import 'moment/locale/pt-br'
import moment from 'moment'
and it was not working in a React project with Typescript.
I got to fix it this way:
import 'moment/dist/locale/pt-br'
Just add the folder 'dist' while you're importing the language. I hope everything works accordingly.
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