-[Up,every,day] 之 №3_JS 每秒更新 年-月-日-星期-时-分-秒-早,中,晚
2010-01-11 13:34
369 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today, theday;
today = new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
theday = today.getYear()+"年" + [today.getMonth()+1]+"月" +today.getDate() + d[today.getDay()+1];
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = theday+xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>
</head>
<body>
<div id="Clock" align="center" style="font-size: 12px; color:#000000"></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today, theday;
today = new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
theday = today.getYear()+"年" + [today.getMonth()+1]+"月" +today.getDate() + d[today.getDay()+1];
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = theday+xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>
</head>
<body>
<div id="Clock" align="center" style="font-size: 12px; color:#000000"></div>
</body>
</html>
相关文章推荐
- -[Up,every,day] 之 №2_.NET Socket 简单的应用,实现服务器与客户端 实时更新对话.!
- js自动更新时间+星期
- vue.js格式化时间并每秒更新
- Practice Every Day_9(更新索引)
- vue.js实现格式化时间并每秒更新显示功能示例
- js获取当前时间并每秒刷新更新
- -[Up,every,day] 之 №1_ ASP.NET GridView读取隐藏列的两种方法
- PHP+JS 实现每秒刷新一次页面---小白作品
- [Everyday Mathematics]20150301
- Cocos2d-JS 热更新
- JavaScript 30 Day -- 13 JS中的引用与复制
- SlipJs3.0.0更新说明
- jquery最新js及chm(随时更新)
- js 动态生成json对象、时时更新json对象
- 前端工程精粹(一):静态资源版本更新与缓存(附精简js的工具)
- js实现页面动态时间,滚动效果(年月日,小时、分钟、秒,星期,毫秒)
- Cocos2d-Js热更新(最完整版本,包括自己做的过程中遇到的坑都在里面)
- asp.net js css 等开发中可能会用到的- 不断更新
- Practice Every Day_2
- countUp.js