I have React Project
and I use moment.js
for work with date. I tried to change language/locale with official documentation, nothing helped, here's my code:
const moment = require('moment');
class Calendar extends Component {
render() {
const variable = moment();
console.log(variable.locale('ru').format('dddd')) // Thursday
console.log(moment.locale('ru')); // en
return (
<div className="calendar-container">
Calendar
</div>
);
}
}
Also I tried import '../../node_modules/moment/src/locale/ru.js'
did't work either(Error: Cannot find module "./locale"). Any idea how fix this?
Try adding:
import 'moment/locale/ru';
and using:
moment.locale('ru');
To set the locale.
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