Parse Date, Month, and Year from Javascript “Date” form

后端 未结 3 1719
后悔当初
后悔当初 2020-12-10 10:16

I am using the following for a user to input a date in a form:


I am wondering if ther

3条回答
  •  暖寄归人
    2020-12-10 10:37

    You may try like this:-

    function parseDate(input) {
      var str= input.split('/');
      return new Date(str[0], str[1]-1, str[2]); 
    }
    

    str[1]-1 as months start from 0.

    You may also check Date.parse(string) but this implemetation dependent.

提交回复
热议问题