此腳本有什麼問題?javascript日期+ 7天
當我設置我的時鐘說29/04/2011它增加了36/4/2011在一週輸入!但正確的日期應該是2011年6月5日
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);
}
'd.getDate()'給你一個整數...它不再是某種日期對象在這一點上... – michelgotta 2011-04-21 08:48:01
我不得不建議只讀通過你在那裏做什麼,並在紙上工作,你的錯誤將是顯而易見的給你。 – Lazarus 2011-04-21 08:48:39