Moment.js: convert timestamp and show month in German

I have problems showing the month of the next operation in German:

var date = moment.unix(valueTimestamp).format("DD. MMMM YYYY");

I tried the following, but it does NOT work:

// Attempt #1:
var date = moment.lang('de').unix(valueTimestamp).format("DD. MMMM YYYY");
// Attempt #2:
var date = moment.local('de').unix(valueTimestamp).format("DD. MMMM YYYY");

How can I make the month name German?

EDIT

I have included the locales.js file and am creating a js script that will demonstrate my problem:

https://jsfiddle.net/e3a7bgLu/

The following error is displayed on the console:

Uncaught TypeError: moment.locale(...).unix is not a function
+4
source share
2 answers

You have a unix constructor AFTER you define the locale. This way you define the locale for nothing.

You need to create a moment before defining the locale.

So, the moment will be created from the method .unix(), and from this return result you can determine the locale on it.

moment.unix(1414543560).locale('de').format("DD. MMMM YYYY");

!:)

JSFiddle

+1

, . . https://jsfiddle.net/e3a7bgLu/2/

, moment.locale, moment.unix.

+1

All Articles