ie8 不支持new Date(2012

使用JS的时候也碰到了如下问题,后来经过修改,在IE8环境里,下面的代码是可用的,下面与大家分享下ie8 不支持new Date的解决方法,有类似问题的朋友可以参考下

我们在使用JS的时候也碰到了如此问题,后来经过修改,在IE8环境里,下面的代码是可用的。

js 结束时间-开始时间,得到天数

复制代码 代码如下:


function getDays(strDateStart,strDateEnd){
var strSeparator = "-"; //日期分隔符
var oDate1;
var oDate2;
var iDays;
oDate1= strDateStart.split(strSeparator);
oDate2= strDateEnd.split(strSeparator);
var strDateS = new Date(oDate1[0], oDate1[1]-1, oDate1[2]);
var strDateE = new Date(oDate2[0], oDate2[1]-1, oDate2[2]);
iDays = parseInt(Math.abs(strDateS - strDateE ) / 1000 / 60 / 60 /24)//把相差的毫秒数转换为天数
return iDays ;
}

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdgyws.html