javascript日期的表达

<html>
<head>
<script type="text/javascript">
function mydate(){
			var time=new Date();
			var year=time.getFullYear();
			var hour=time.getHours();
			var mon=time.getMonth()+1;
			var day=time.getDate();
			var minu=time.getMinutes();
			var sec=time.getSeconds();
			hour=change(hour);
			minu=change(minu);
			sec=change(sec);
			document.getElementById("dat").innerHTML=year+"-"+mon+"-"+day+" "+hour+":"+minu+":"+sec;
			t=setTimeout("mydate()",500);
		}
		function change(num){
			if(num<10){
				return "0"+num;
			}
			else{
				return num;
			}
		}
</script>
</head>

<body onload="mydate()">
<div id="dat"></div>
</body>
</html>

javascript日期的表达

上一篇:html转义字符本文


下一篇:html5烟花绽放