/** * 日期加减 * @param dayNum 可为负数,为负数时,是减去天数。 * @returns {String} */ function addDate(dayNum){ var now = new Date(); var years = now.getFullYear(); var months = now.getMonth()+1; var days = now.getDate(); var hours = now.getHours(); var a = new Date(months+"/"+days+"/"+years); a = a.valueOf(); a = a + (dayNum) * 24 * 60 * 60 * 1000; a = new Date(a); var newDate = a; years = newDate.getFullYear(); months = newDate.getMonth()+1; days = newDate.getDate(); var resultDate=years+"-"+months+"-"+days; alert("结果日期:"+resultDate); return resultDate; }
js 日期加减
猜你喜欢
转载自blog.csdn.net/qq_27435059/article/details/80011262
今日推荐
周排行