js时钟

<html>
<head>
<script type="text/javascript">
     function Clock() {

            var myDate = new Date();
            var year = myDate.getYear();
            var month = myDate.getMonth()+1;
            var day = myDate.getDay();
            var hour = myDate.getHours();
            var minute = myDate.getMinutes();
            var second = myDate.getSeconds();

            var time = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;

            var spOjb = document.getElementById("spTimer");
            spOjb.innerText = time;
           
        }
		
	function Run()
	{
		 Clock();
		 window.setInterval("Clock()", 1000);
	}

</script>
</head>
<body onload="Run()">
    <span id="spTimer"></span>
</body>
</html>

 

你可能感兴趣的:(Date,function)