Browser compatibility issues with new Date()

When creating a date object with new Date(str);:

Google Chrome:


Firefox browser:


Internet Explorer:


It can be seen that the date generated under the ie browser is illegal. After consulting the data, it is found that ie does not support "-", while "/" is supported under all browsers, so the processing is as follows:

var str = "2018-05-02 20:00:00";
var dateStr = new Date(str.replace(/-/g,"/"));
dateStr
Use "/" to connect, all browsers are correct.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325217596&siteId=291194637