new Date(date).getTime() is not compatible with iPhone

I encountered a big hole today.
new Date(date).getTime(),Using this method to get the timestamp,
it is NaN on the mobile phone, and there is no problem in the Google browser!
Because it is a real machine debugging, it is time-consuming and laborious.
I'm just wondering what's wrong with such a simple method.

After working overtime to find a solution, I found in a small corner that
new Date(date).getTime()it is not compatible with Apple phones.
Although it is a small compatibility problem,
but without this experience, I have delayed myself for too long.

Solution:

new Date(data.replace(/-/g,'/')).getTime()
data是字符串,格式类似于:‘2018-09-09 23:23:23’

I don't think I'll ever forget this compatibility issue for the rest of my life.

Guess you like

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