I get for example: 1day ago. What I need is to set for different language, for example for de
. Any suggestion how can I do that?
moment(Date.
See official docs on how changing locale globally.
Note that you have to import locale data (e.g. moment-with-locales.min.js)
Here a working example:
moment.locale('de');
console.log(moment(Date.now()).fromNow()); //vor ein paar Sekunden
You can also use only data for a given locale (e.g. de
):
moment.locale('de');
console.log(moment(Date.now()).fromNow()); //vor ein paar Sekunden
Moreover you are redefining moment in your code, that is incorrect
var moment = moment();