JQuuery中根据制定日期计算加减之后的日期方法
//date 日期
//count 天数
function dateClac(date,count){
var startTime = new Date(date).getTime() + 24 * 60 * 60 * 1000 * count;//加count天
var startYear = new Date(startTime).getFullYear(); //获取新的日期的年份
var startMonth = new Date(startTime).getMonth() + 1;//获取月份
var startDay = new Date(startTime).getDate(); //获取天
return startYear + "-" + appendZero(startMonth) + "-" + appendZero(startDay)
}
//如果月份或者天数小于10则自动追加0
function appendZero(obj){
if(obj < 10){
return "0" + obj
} else{
return obj
}
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-10329.html