JAVA web 获取系统时间

<HTML>
<HEAD>
	<SCRIPT LANGUAGE="JavaScript">
		var strTime, strDate;
		function webClock()
		{
			var dNow = new Date();
			var dHours = dNow.getHours();
			var dMinutes = dNow.getMinutes();
			var dSeconds = dNow.getSeconds();
			strTime = dHours;
			strTime += ((dMinutes<10) ? ":0" : ":") + dMinutes;
			strTime += ((dSeconds<10) ? ":0" : ":") + dSeconds;
			clock.time.value = strTime;
			
			var dDate = dNow.getDate();
			var dMonth = dNow.getMonth() + 1;
			var dYear = dNow.getYear();
			strDate = dMonth;
			strDate += ((dDate<10) ? "/0" : "/") + dDate;
			strDate += "/" + dYear;
			clock.date.value = strDate;
			setTimeout("webClock()",1000);
		}
	</SCRIPT>
	<TITLE></TITLE>
</HEAD>
<BODY ONLOAD="webClock()">
	<FORM NAME="clock">
		时间:<INPUT TYPE="TEXT" NAME="time" SIZE="10"><BR>
		日期:<INPUT TYPE="TEXT" NAME="date" SIZE="10"><BR>
	</FORM>
</BODY>
</HTML>

 

发布了32 篇原创文章 · 获赞 106 · 访问量 1万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览