js计算指定天数后的日期

发布时间:2020-06-26编辑:脚本学堂
用js计算天数,求指定天数后的日期,js时间计算的小例子,有需要的朋友参考下。

例子,通过程序来计算指定天数后的日期。
 

复制代码 代码示例:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>计算几天后的日期,js天数计算、时间计算-www.jb200.com</title>
<style type="text/css">
<!--
body {  font-family: "宋体"; font-size: 9pt; margin-top: 0px; margin-left: 0px; margin-right: 0px}
A { COLOR: black; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: none }
A:hover { COLOR: red; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: underline }
a:active     { font: 9pt "宋体"; cursor: hand; color: #FF0033 }
-->
</style>
</head>
<body>

<center><font color=red face="隶书" size=6>记录几天后的日期</font></center>
<center>
<table border=0 bordercolor=blue borderlight=green style="border-collapse: collapse" cellpadding="0" cellspacing="0">
<tr><td align=center><font size=5 color=red face="Arial, Helvetica, sans-serif"><strong>下面为效果显示区!</strong></font></td></tr><tr><td align=center> <script language="javascript">
<!-- Begin
function AddDays(form) {
DaysToAdd=document.form.DaysToAdd.value;
var now=new Date();
var newdate=new Date();
var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
newdate.setTime(newtimems);
document.form.display.value=newdate.toLocaleString();
}
// End -->
</script>
<form name=form>
<input type=text name=DaysToAdd size=4 value=10 onFocus="this.select()" onMouseOver="this.focus()">
<input type=button value="天后的日期将是.." onClick="AddDays(this.form)" name="button">
<input type=text name="display" size=20 value="">
</form>
</td></tr>
</table></center>
<center>
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
function goHist(a)
{//www.jb200.com
   history.go(a);
}
//-->
</script></center>
</body>
</html>