JavaScript 动态显示系统时间

JavaScript 动态显示系统时间


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>

<script language="javascript" type="text/javascript">
//动态显示当前的时间
function GetTime(obj)
{
var myDate = new Date();
var Today = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
//获取当前年
var Years = myDate.getFullYear();
//获取当前月
var Months = myDate.getMonth() + 1;
//获取当前日
var Dates = myDate.getDate();

//获取当前天是当前周的第几天
var Days = Today[myDate.getDay()];

//获取当前的时
var Hours = myDate.getHours();
//获取当前的分
var Minutes = myDate.getMinutes();
//获取当前的秒
var Seconds = myDate.getSeconds();

Months = Months < 10 ? '0' + Months : Months;
Dates = Dates < 10 ? '0' + Dates : Dates;

Hours = Hours < 10 ? '0' + Hours : Hours;
Minutes = Minutes < 10 ? '0' + Minutes : Minutes;
Seconds = Seconds < 10 ? '0' + Seconds : Seconds;

obj.value = Years + '年' + Months + '月' + Dates + '日' + ' ' + Days + ' ' + Hours + ':' + Minutes + ':' + Seconds;

//每隔一秒重新调用GetTime函数
setTimeout("GetTime(document.getElementById('ShowTime'))","1000");
}
</script>

</head>
<body onload="GetTime(document.getElementById('ShowTime'))">
<form id="form1" runat="server">
<div>
<input id="ShowTime" type="text" style="width: 511px" />
</div>
</form>
</body>
</html>




http://www.cnblogs.com/ziyun/archive/2010/01/26/1656620.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值