Validate number of days in a given month

前端 未结 13 2142
独厮守ぢ
独厮守ぢ 2021-01-31 18:14

Performance is of the utmost importance on this one guys... This thing needs to be lightning fast!


How would you validate the number of days in a given mont

13条回答
  •  猫巷女王i
    2021-01-31 18:25

    Moment.js

    Have you tried moment.js?

    The validation is quite easy to use:

    var m = moment("2015-11-32");
    m.isValid(); // false
    

    I don't know about the performances but hum the project is stared 11,000+ times on GitHub (kind of a quality guarantee).

    Source: http://momentjs.com/docs/#/parsing/is-valid/

提交回复
热议问题