CodeYoga
CodeYoga

Reputation: 35

incorrect momentjs formatting output (using examples from their main page)

var moment = require('momentjs');
console.log(moment().format('MMMM Do YYYY, h:mm:ss a')); // October 20th 2016, 12:13:24 pm
console.log(moment().format('dddd'));                    // Thursday
console.log(moment().format("MMM Do YY"));               // Oct 20th 16
console.log(moment().format('YYYY [escaped] YYYY'));     // 2016 escaped 2016

Actual output on my nodejs windoze env is:

node test.js

101010 20o 2016, 12:21:44 a

202020

1010 20o 16

2016 [e44cape20] 16YY

Any idea what is going on here?

Upvotes: 1

Views: 153

Answers (1)

Matt Johnson-Pint
Matt Johnson-Pint

Reputation: 241535

You are importing the wrong package from NPM. The package name for moment.js is simply moment.

Unfortunately, someone else is trying to confuse people by creating a different package with a similar API and registering it as momentjs. More on this here: https://github.com/vvpvvp/momentjs/issues/2

Upvotes: 3

Related Questions