js-設定時間,獲取幾天後的時間
阿新 • • 發佈:2019-01-04
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>設定時間</title>
</head>
<body>
<p></p>
<script type="text/javascript">
var oP=document.getElementsByTagName("p")[0]
var today=new Date();
var year=today.getFullYear();
var month=today.getMonth();
var date=today.getDate();
var weeks=["日","一","二","三","四","五","六"]
var temp=new Date(year,month,date+8)
oP.innerHTML="八天後是"+temp.getFullYear()+"-"+(temp.getMonth()+1)+"-"+temp.getDate()+"-"+"星期"+weeks[temp.getDay()]
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>設定時間</title>
</head>
<body>
<p></p>
<script type="text/javascript">
var oP=document.getElementsByTagName("p")[0]
var today=new Date();
var year=today.getFullYear();
var month=today.getMonth();
var date=today.getDate();
var weeks=["日","一","二","三","四","五","六"]
var temp=new Date(year,month,date+8)
oP.innerHTML="八天後是"+temp.getFullYear()+"-"+(temp.getMonth()+1)+"-"+temp.getDate()+"-"+"星期"+weeks[temp.getDay()]
</script>
</body>
</html>