Error: Invalid Date(2019.06.06 13:12:49); error: Invalid Date(2019.06.06 13:12:49); There is no problem with using wechat development tools, mobile phone development version and mobile phone experience version, which cannot be displayed in ios.

Dd: 2018-12-10:2018-12-10:2018-12-10:2018-12-10:2018-12-10:2018-12-10:2018-12-10

Error message in Safari: 2018.12.10 11:11:11 Date format

Error Message: 2018-12-10 11:11:11 Date format in Safari

So replace is the regular replacement

let dateStr1 = '2018.12.10 11:11:11';
let dateStr2 = 'the 2018-12-10 11:11:11'; /* Replace "- or" in time with a regular expression. */ dateToTimestamp(dateStr) {if(! dateStr) {return ' '
    }
    let newDataStr = dateStr.replace(/\.|\-/g, '/')
    let date = new Date(newDataStr);
    let timestamp = date.getTime();
    return timestamp
}

this.dateToTimestamp(dateStr1)
this.dateToTimestamp(dateStr2)
Copy the code

In order to verify my idea, I checked stackOverflow and found several similar questions. Here is a representative one:

Safari JS cannot parse YYYY-MM-DD date format?

Parse the new Date(string) parse is implemented differently in different browsers. Chrome supports both formats and Safari only supports YYYY /mm/ DD.

PS: RECENTLY, I started to do mobile terminal development. I will encounter many compatibility problems in the future. I keep summarizing.