Convert dd-mm-yyyy string to date

后端 未结 14 2154
孤城傲影
孤城傲影 2020-11-22 05:09

i am trying to convert a string in the format dd-mm-yyyy into a date object in JavaScript using the following:

 var from = $(\"#datepicker\").val();
 var to          


        
14条回答
  •  耶瑟儿~
    2020-11-22 05:59

    You can also write a date inside the parentheses of the Date() object, like these:

    new Date("Month dd, yyyy hh:mm:ss")
    new Date("Month dd, yyyy")
    new Date(yyyy,mm,dd,hh,mm,ss)
    new Date(yyyy,mm,dd)
    new Date(milliseconds)
    

提交回复
热议问题