Parse 'Date & Time' string in Javascript which are of custom format

前端 未结 5 1156
-上瘾入骨i
-上瘾入骨i 2020-11-30 10:08

I have to parse a date and time string of format \"2015-01-16 22:15:00\". I want to parse this into JavaScript Date Object. Any help on this?

I tried some jquery plu

5条回答
  •  醉酒成梦
    2020-11-30 10:31

    With moment.js you can create a moment object using the String+Format constructor:

    var momentDate = moment('2015-01-16 22:15:00', 'YYYY-MM-DD HH:mm:ss');
    

    Then, you can convert it to JavaScript Date Object using toDate() method:

    var jsDate = momentDate.toDate();
    

提交回复
热议问题