Date string: 2018-02-07 17:09
var dateString = '2018-02-07 17:09'; date = new Date(dateString.replace(/-/g, "\/")); console.trace(date, date.constructor);// Wed Feb 07 2018 17:09:00 GMT+0800 (CST) ƒ Date() { [native code] }
This example shows that the constructor of the JavaScript Date class supports input strings, but the format must be: 'yyyy/MM/dd HH:mm:ss' format.