解决ios时间包含"-"不显示的bug

一般我们在页面渲染时间的时候都是 xx年-xx月-xx日,这种格式的日期在ios系统里是无法显示的,

将xx年-xx月-xx日的时间格式改为xx年/xx月/xx日就可以解决这个问题。

//获取时间戳
function formatTimeStamp(date,time='0:0:0'){
  return Date.parse(new Date(`${date} ${time}`))||Date.parse(new Date(`${date.replace(/-/g,'/')} ${time}`))
}
console.log(formatTimeStamp('2020-11-11')); //1605024000000
 
原文地址:https://www.cnblogs.com/ZerlinM/p/13594514.html