如何解决ie8 不支持new Date('2012-11-10')的问题
2013-07-30 16:43
633 查看
我们在使用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 ;
}
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 ;
}
相关文章推荐
- ie8 不支持new Date(2012-11-10)问题的解决方法
- ie8 不支持new Date(2012-11-10)问题的解决方法
- VS2013中如何解决error C4996: 'fopen'问题
- 如何有效地解决ie7,IE8不支持document.getElmentsByClassName的问题
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 兼容IE8的js格式化日期方法,解决ie8不支持Date()的问题
- idhttp1.get('www.google.cn')时报 Invalid argument to date encode错误,如何解决。
- IE7,IE8不支持New Date的解决方法
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- VS2013中如何解决'fopen' 报错说unsafe的问题
- 编译过程中弹出new(35) : error C2061: syntax error : identifier 'THIS_FILE'问题的原因及解决方法
- 如何解决adb命令报错 "ADB server didn't ACK"问题
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- VS2013中如何解决error C4996: 'fopen'问题
- 解决IE浏览器中javascript,js不支持NEW DATE()带参数的问题
- 如何解决Error: Can't create a new thread (errno 12)
- LUA中Attempt to call a non-callable object或attempt to call field 'new' (a nil value)问题的解决
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- ie8 不支持new Date('2012-11-10')