javascript日期+ 7天 [英] javascript date + 7 days
本文介绍了javascript日期+ 7天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个脚本有什么问题?
当我把我的时钟表示为29/04/2011时,它会添加 36/4/2011 在本周输入!但正确的日期应为 6/5/2011
When I set my clock to say 29/04/2011 it adds 36/4/2011 in the week input! but the correct date should be 6/5/2011
var d = new Date();
var curr_date = d.getDate();
var tomo_date = d.getDate()+1;
var seven_date = d.getDate()+7;
var curr_month = d.getMonth();
curr_month++;
var curr_year = d.getFullYear();
var tomorrowsDate =(tomo_date + "/" + curr_month + "/" + curr_year);
var weekDate =(seven_date + "/" + curr_month + "/" + curr_year);
{
jQuery("input[id*='tomorrow']").val(tomorrowsDate);
jQuery("input[id*='week']").val(weekDate);
}
推荐答案
var date = new Date();
date.setDate(date.getDate() + 7);
var dateMsg = date.getDate()+'/'+ (date.getMonth()+1) +'/'+date.getFullYear();
alert(dateMsg);
这篇关于javascript日期+ 7天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文