I'm trying to format a date into german locale with moment.js, Version 2.11.0:
var moment = require('moment');
moment.locale("de");
console.log(moment(new Date()).locale('de').format('L'));
console.log(moment(new Date()).locale('de_DE').format('L'));
The response remains in english format:
01/05/2016
01/05/2016
Also, the following code should return something in french:
var moment = require('moment');
moment.locale('fr');
console.log( moment(1316116057189).fromNow() );
il y a une heure
But it prints:
4 years ago
I followed the instructions on the docs. But either they are wrong or i misunderstood... Anyhow, the locale-method isn't working as expected. I installed moment with npm into an react native project. It contains lots of locale-files under a subdirectory. So, missing files could not be the root cause of this issue.
Update:
According to the comments, changing the require-statement to this one will work:
var moment = require('moment/min/moment-with-locales.js');