Parse Date String to Date in JavaScript

后端 未结 3 1922
挽巷
挽巷 2021-01-27 03:57

I have this date string \"2013:05:12 11:41:31\"

I tried:

var strDate = \"2013:05:12 11:41:31\";
var dateParts = strDate.split(\":\");

var date = new Da         


        
3条回答
  •  野性不改
    2021-01-27 04:29

    You might consider using moment.js for this.

    var strDate = "2013:05:12 11:41:31";
    var date = moment(strDate, "YYYY:MM:DD HH:mm:ss").toDate();
    

提交回复
热议问题