new Date() 在iOS 的兼容

在iOS 中 如果时间是 new Date("2017-08-08") 这种样式时,会直接返回NaN ,如果想要得到正确的时间格式,需要将其转换为 new Date("2017/08/08") 这种格式的

var str = "2017-08-08";
str = str.replace(/-/g,"/");
new Date(str);

  

posted @ 2017-11-07 14:47  Nextfuture  阅读(94)  评论(0编辑  收藏  举报