var dateTimeNow = d.getFullYear() +( d.getMonth() + 1) +d.getDate() + (d.getHours() +1)+ d.getMinutes() + d.getSeconds()
<html><head>
<title>JS时间累加</title>
<script type="text/javascript">
function RunTime()
{
var now = new Date()
//当前时间
var hours = now.getHours()//时
var minutes = now.getMinutes()//分
var seconds = now.getSeconds()//秒
document.getElementById("NowTime").innerHTML = hours+"时"+minutes+"分"+seconds+"秒"
//秒加时
now = new Date(now.getTime() + (1000*parseInt(document.getElementById("Jtime").value)))//这里是关键
var hoursS = now.getHours()//时
var minutesS = now.getMinutes()//分
var secondsS = now.getSeconds()//秒
document.getElementById("oldTime").innerHTML = hoursS+"时"+minutesS+"分"+secondsS+"秒"
}
</script>
<style type="text/css">
.style1
{
width: 133px
}
</style>
</head>
<body onload="javascript:document.all('Jtime').focus()">
<table align="center">
<tr><td class="style1">当前时间:</td><td colspan="2"><label id="NowTime"></label></td></tr>
<tr><td class="style1">加时之后:</td><td colspan="2"><label id="oldTime"></label></td></tr>
<tr><td class="style1">输入加入时间/秒:</td><td><input id="Jtime"/></td><td><button id="BtnTime" name="BtTime" onclick="RunTime()">计算</button></td></tr>
</table>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)