JS date format and date comparison

后端 未结 2 1512
遇见更好的自我
遇见更好的自我 2021-01-22 04:02

I Have a date in this format

 16-NOV-12 

From an input box with id = date.

How do I check if this date is in the past of future?

2条回答
  •  余生分开走
    2021-01-22 04:39

    Try something like this:-

     var selectedDate = $('16-Nov-12').datepicker('getDate');
     var now = new Date();
     if (selectedDate < now) {
        // selected date is in the past
     }
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题