How can I determine whether a given string represents a date?

后端 未结 11 1621
一个人的身影
一个人的身影 2020-12-11 00:31

Is there an isDate function in jQuery?

It should return true if the input is a date, and false otherwise.

11条回答
  •  攒了一身酷
    2020-12-11 01:25

    Date.parse will prb sort you out, without the need for jquery:

    http://www.w3schools.com/jsref/jsref_parse.asp

    Above removed after some kind soul pointed out how basic parseDate really is.

    There is also a $.datepicker.parseDate( format, value, options ) utility function in the JQuery UI Datepicker plugin:

    https://api.jqueryui.com/datepicker/

提交回复
热议问题