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

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();

Leave a Comment