今日の残り時間を計算して表示

<html>
<head>
<script type="text/javascript">
<!--
function time() {

var now = new Date();
var hour = 23-now.getHours();
var min = 59-now.getMinutes();
var sec = 59-now.getSeconds();

document.getElementById("ptime").innerHTML = ""+hour+"時間"+min+"分"+sec+"秒";
window.setTimeout("time()", 500);

}

// -->
</script>
</head>
<body onload="time()">
<div id="ptime"></div>
</body>
</html>

コメントを残す