Moment.js 2-digit year converts an invalid 4-digit year

Has anyone encountered this problem with Moment.js: in Firefox using the moment ("6/12/15"). format ("M / D / YYYY h: mm: ss A") Am I getting 6/12/1915 instead of 6/12/2015?

+4
source share
1 answer

When you throw a random string in momentwithout telling it what format it is in, it returns to the JavaScript object Datefor parsing, and the format you pass is not defined by the standard. This gives you wide disclosure for implementation-specific behavior. In this case, what you are describing happens in Firefox, but not in Chrome.

, Moment .

, Moment, :

moment("6/12/15", "M/D/YY").format("M/D/YYYY h:mm:ss A")
+6

All Articles