ie8 不支持new Date(2012-11-10)问题的解决方法
浏览:22日期:2024-06-07
我们在使用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 ; }
相关文章:
热门推荐
- intellij idea和eclipse比较
- 1.Golang压缩Jpeg图片和PNG图片的操作
- 2.如何在FreeBSD上用PHP实现在线添加FTP用户
- 3.Fedora 8 JDK Eclipse Myeclispe安装配置
- 4.Solaris如何增加用户?(groupadd,useradd)
- 5.Linux下安PHP,APACHE,MYSQL,PERL方法 4
- 6.浅析NIO系列之TCP
- 7.Data Blocks and Freelists (from ixora)
- 8.IE6下css设置容器高度的BUG不能小于某个值
- 9.Linux下安PHP,APACHE,MYSQL,PERL方法2
- 10.编程面试过程中常见的10大算法概念汇总