兼容不同的浏览器时间
2017-03-01 21:50
176 查看
function addDate(date, days) {
//For the sake of browser incompatibility between doing format conversion
var getDate= new Date(Date.parse(date.replace(/-/g, “/”)));
// var newdate;
// if(typeof date == “string” )
// newdate = Date.parse(date);
// else
// newdate = date;
//The date of the string into a millisecond
var d = new Date(getDate.getTime());
d.setDate(d.getDate() + days);
// For years of time
// var yy = d.getYear();
var yy = d.getFullYear();
// Judgment in time
if (yy < 1900)
yy = yy + 1900;
// For months
var MM = d.getMonth() + 1;
if (MM < 10)
MM = ‘0’ + MM;
// For days
var dd = d.getDate();
if (dd < 10)
dd = ‘0’ + dd;
return yy + ‘-’ + MM + ‘-’ + dd;
// return d.getFullYear()+’-‘+(d.getMonth()+1)+’-‘+d.getDate();
}
//For the sake of browser incompatibility between doing format conversion
var getDate= new Date(Date.parse(date.replace(/-/g, “/”)));
// var newdate;
// if(typeof date == “string” )
// newdate = Date.parse(date);
// else
// newdate = date;
//The date of the string into a millisecond
var d = new Date(getDate.getTime());
d.setDate(d.getDate() + days);
// For years of time
// var yy = d.getYear();
var yy = d.getFullYear();
// Judgment in time
if (yy < 1900)
yy = yy + 1900;
// For months
var MM = d.getMonth() + 1;
if (MM < 10)
MM = ‘0’ + MM;
// For days
var dd = d.getDate();
if (dd < 10)
dd = ‘0’ + dd;
return yy + ‘-’ + MM + ‘-’ + dd;
// return d.getFullYear()+’-‘+(d.getMonth()+1)+’-‘+d.getDate();
}
相关文章推荐
- javascript在不同浏览器下的兼容问题已经遇到的疑难杂症
- JS实时显示当前时间(IE+firefox)浏览器兼容代码(图证)
- XMLHttp兼容多种不同版本的浏览器
- IE、FF、Safari、OP不同浏览器兼容报告
- 兼容在不同浏览器不同分辨率下DIV高度自适应
- [转]小技巧 争对不同浏览器写不同的CSS 来兼容浏览器
- 兼容不同浏览器的音频文件(mp3)播放实现
- 利用IE/FF的不同识别CSS来使用浏览器兼容问题
- CSS在不同浏览器上的兼容问题
- 根据不同浏览器调用不同css解决兼容问题
- JS实时显示当前时间(IE+firefox)浏览器兼容代码(图证)
- 网页鼠标指针效果在不同浏览器下兼容
- 盒型详解及不同浏览器兼容
- 有关css和js针对不同浏览器兼容的问题
- 在不同的浏览器使用不同的css样式,解决浏览器兼容问题
- 有关css和js针对不同浏览器兼容的问题
- 网站优化-前端设计在不同浏览器上面的兼容
- 在不同的浏览器使用不同的css样式,解决浏览器兼容问题
- jquery的不同写法可能造成浏览器的不兼容问题!
- css 兼容通过判断不同的浏览器