标签:日期类 nbsp eth 计算 default string类 inter 0.00 str
//计算日期加法 function DateAdd(interval, number, date) { switch (interval) { case "y": { date.setFullYear(date.getFullYear() + number); return date; break; } case "q": { date.setMonth(date.getMonth() + number * 3); return date; break; } case "m": { date.setMonth(date.getMonth() + number); return date; break; } case "w": { date.setDate(date.getDate() + number * 7); return date; break; } case "d": { date.setDate(date.getDate() + number); return date; break; } case "h": { date.setHours(date.getHours() + number); return date; break; } case "m": { date.setMinutes(date.getMinutes() + number); return date; break; } case "s": { date.setSeconds(date.getSeconds() + number); return date; break; } default: { date.setDate(d.getDate() + number); return date; break; } } }
//把String类的日期转换为Date类 var date = new Date(2017-09-14 00:00:00.000); //然后计算 var nextDate = DateAdd("y",3,date)
标签:日期类 nbsp eth 计算 default string类 inter 0.00 str
原文地址:http://www.cnblogs.com/LYT731013/p/7526636.html