js输出时间代码
2013-04-17 10:03
260 查看
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function Time()
{
var date = new Date();
var hour=date.getHours();
var min=date.getMinutes();
var sec=date.getSeconds();
var apm="AM";
if(hour>12)
{
apm="PM";
hour="0"+(hour-12);
}
if(min<10)
{min="0"+min;
}
if(sec<10)
{sec="0"+sec;
}
document.getElementById("timer").value=hour+":"+min+":"+sec+""+apm;
c=setTimeout("Time(),1000");
}
</script>
</head>
<body onload="Time()" bgcolor="#00FF00">
<center>当前系统时间为:<input type="text" id="timer" style="width:200px"/>
<input type="button" id="top" style="width:auto" value="时间停止" onclick="clearTimeout(c)" />
</center>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function Time()
{
var date = new Date();
var hour=date.getHours();
var min=date.getMinutes();
var sec=date.getSeconds();
var apm="AM";
if(hour>12)
{
apm="PM";
hour="0"+(hour-12);
}
if(min<10)
{min="0"+min;
}
if(sec<10)
{sec="0"+sec;
}
document.getElementById("timer").value=hour+":"+min+":"+sec+""+apm;
c=setTimeout("Time(),1000");
}
</script>
</head>
<body onload="Time()" bgcolor="#00FF00">
<center>当前系统时间为:<input type="text" id="timer" style="width:200px"/>
<input type="button" id="top" style="width:auto" value="时间停止" onclick="clearTimeout(c)" />
</center>
</body>
</html>
相关文章推荐
- js两行代码按指定格式输出日期时间
- js两行代码按指定格式输出日期时间
- js 取时间代码
- js获得当前日期和时间的代码
- JavaScript 逼真图片倒计时实现代码 js时间图片倒计时
- js时间代码
- js 获取当前时间输出并刷新date
- 输出到网页前台js代码中包含单引号的处理方法
- js停止输出代码
- JS根据时间内容分组代码
- js查看一个函数的执行时间实例代码
- js 输出内容到新窗口具体实现代码
- JS-纯JavaScript代码显示系统当前时间
- 这段js代码得拯救你多少时间
- 等待指定时间后自动跳转或关闭当前页面的js代码
- JS输出当前时间,且每秒变化
- calendar.js时间控件代码
- 等待指定时间后自动跳转或关闭当前页面的js代码
- js用Date对象处理时间实现思路及代码