`
shenshuibomb
  • 浏览: 24527 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

在网页上显示系统时间

阅读更多


<html>
<head>
<title>
Show the current time
</title>
<script>
var temp = null;
var timeValue = null;
function divCon()
{
temp = document.getElementById('thetime');
temp.innerText = "Time: " + timeValue;

}
var timerID = null;
var timerRunning = false;
function stopclock()
{
if(timerRunning)
{
clearTimeout(timerID);
}
timerRunning = false;
}
function startclock()
{
stopclock();
showtime();
}

function showtime()
{
var now = new Date(); //Get the current time
var hours = now.getHours(); //Get the current hours
var minutes = now.getMinutes(); //Get the current minutes
var seconds = now.getSeconds(); //Get the current seconds
timeValue = "" +((hours>12)?"PM ":"AM "); //以12?制?示系???
timeValue += ((hours>12)?hours-12:hours);
timeValue += ((minutes<10)?":0":":") + minutes;    //以双位显示
timeValue += ((seconds<10)?":0":":") + seconds;    //以双位显示
divCon();
timerID = setTimeout("showtime()",1000); //间隔1000毫秒,即1秒
timerRunning = true;
}
</script>
</head>
<body onload="divCon();startclock()">
<center>
<h1>TIME</h1>
<form name = "clock" id = "clock">
<div name="thetime" id ="thetime"></div>
</form>
</center>
</body>
</html>

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><font color="#000000"><img height="585" alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/shenshuibomb/EntryImages/20081223/Date.JPG" width="923"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Century; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'MS 明朝'; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: JA; mso-bidi-language: AR-SA"><shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><lock v:ext="edit" aspectratio="t"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 425.25pt; HEIGHT: 269.25pt" type="#_x0000_t75"><imagedata src="file:///C:%5CDOCUME~1%5Cwangzhi%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image001.png" o:title="Date"></imagedata></shape></span><stroke joinstyle="miter"></stroke></font><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path><lock v:ext="edit" aspectratio="t"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 425.25pt; HEIGHT: 269.25pt" type="#_x0000_t75"><imagedata src="file:///C:%5CDOCUME~1%5Cwangzhi%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image001.png" o:title="Date"></imagedata></shape>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics