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();
}
兼容不同的浏览器时间
最新推荐文章于 2024-11-08 14:35:14 发布