jQuery时间日期不兼容(苹果手机出现时间解析失败)
发布日期:2021-05-06 22:12:04 浏览次数:26 分类:技术文章

本文共 583 字,大约阅读时间需要 1 分钟。

一、复现

解析失败代码,&& nowDate<endDate 比较大小时失败

var endDate = new Date(vo.applyEndDate).getTime();var nowDate = new Date().getTime();if (parseInt(vo.surplus)>0 && nowDate

二、解决办法

使用 .replace(/-/g,'/')  转换时间格式

var endDate = new Date(vo.endDate.replace(/-/g,'/')).getTime();var applyStartDate = new Date(vo.applyStartDate.replace(/-/g,'/')).getTime();var applyEndDate = new Date(vo.applyEndDate.replace(/-/g,'/')).getTime();var nowDate = new Date().getTime();if (parseInt(vo.surplus)>0 && nowDate>applyStartDate && nowDate

 

 

三、.replace(/-/g,'/') 的使用

一般的时间格式:2016-1-1 

.replace(/-/g,'/') 转换后:2016/1/1

 

上一篇:vue项目中报/sockjs-node/info错误
下一篇:ELK分布式事务管理——Logstash

发表评论

最新留言

很好
[***.229.124.182]2025年03月14日 14时11分14秒