Apple mobile phone new Date () compatible problem handling

Using new Date(date).getTime() on an Apple phone (IOS) will return NaN, which is not as expected, but it can be used normally on an Android phone

new Date(date) compatible method:

//兼容 IOS new date
getDate(strdate){
    
    
	var arr = strdate.split(/[- : \/]/);
	var date = new Date(arr[0], arr[1] - 1, arr[2], arr[3], arr[4], arr[5]);
	return date;
},

Instructions:

let data = getDate("2023-01-02")//获取 Date
let timestamp = data.getTime()//获取时间戳

Guess you like

Origin blog.csdn.net/weixin_44646763/article/details/128535494