Why is moment.js allowing date with one digit year when using strict parsing?

后端 未结 1 711
逝去的感伤
逝去的感伤 2021-01-20 18:09

I am using moment.js to parse a date. http://momentjs.com/docs/#/parsing/string-format/

This is to validate and convert the date to a format required by my database.

1条回答
  •  生来不讨喜
    2021-01-20 18:49

    This was a known issue for past versions of Moment.js: YYYY-MM-DD with 3 digit year returns true for isValid().

    It was fixed in December 2013, and your code works as expected with the most recent version of the library. Version 2.3.1 was released in October 2013 and does not include this fix.

    0 讨论(0)
提交回复
热议问题