计算一定天数后的日期
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<button onClick="btnDayCount_Click();">计算一定天数后的日期</button>
<script type="text/javascript" > // language="JavaScript"
function btnDayCount_Click() {
var today=new Date();
var initDay=100;//100天
var endDay=null;
var times=today.getTime()+100*24*60*60*1000;
var endDay=new Date(times);
alert(endDay.getFullYear()+"-"+(endDay.getMonth()+1)+"-"+endDay.getDate());
//上面的100代表100天后的日期,你可以修改。JS中Date.getTime(),只能1970.01.01之后的日期;还有月份是0 - 11,有点不一样,切忌哦。当然你也可以计算特定日期后的日期。
}
</script>
<script language="javascript" type="text/javascript">
var startDate = new Date (2007, (8-1), 1, 10, 10, 10);
alert(startDate.getFullYear()+"-"+(startDate.getMonth()+1)+"-"+startDate.getDate());
var intValue = 0;
var endDate = null;
intValue = startDate.getTime(); intValue += 100 * (24 * 3600 * 1000);
endDate = new Date (intValue);
alert (endDate.getFullYear()+"-"+ (endDate.getMonth()+1)+"-"+ endDate.getDate());
</script>
</body>
</html>