JS日期时间代码
2012-06-01 14:08
267 查看
<!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>JavaScript在线时钟,时间</title>
<script type="text/javascript">
function tim(){
var now=new Date;
this.year = now.getFullYear();
this.tmonth = now.getMonth() + 1;
this.tday = now.getDate();
this.week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")[now.getDay()];
this.month = tmonth < 10 ? "0" + tmonth : tmonth;
this.day = tday < 10 ? "0" + tday : tday;
this.hour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
this.minute = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
this.second = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
document.getElementById("timespan").innerHTML="今天是"+year+"年"+month+"月"+day+"日,"+hour+":"+minute+":"+second+","+week;
var mm=setTimeout("tim()","1000");
}
</script>
</head>
<body onLoad="tim()">
<span id="timespan"></span>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JavaScript在线时钟,时间</title>
<script type="text/javascript">
function tim(){
var now=new Date;
this.year = now.getFullYear();
this.tmonth = now.getMonth() + 1;
this.tday = now.getDate();
this.week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")[now.getDay()];
this.month = tmonth < 10 ? "0" + tmonth : tmonth;
this.day = tday < 10 ? "0" + tday : tday;
this.hour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
this.minute = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
this.second = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
document.getElementById("timespan").innerHTML="今天是"+year+"年"+month+"月"+day+"日,"+hour+":"+minute+":"+second+","+week;
var mm=setTimeout("tim()","1000");
}
</script>
</head>
<body onLoad="tim()">
<span id="timespan"></span>
</body>
</html>
相关文章推荐
- JS 显示当前日期与时间的代码
- Js 获取当前日期时间及其它操作实现代码
- javascript 日期时间控件 js代码
- 如何在JS中获取当前日期时间及其它操作的代码
- JS 取当前日期、时间的代码
- js动态显示当前日期,时间和星期代码
- JS 显示当前日期与时间的代码
- JS实现网页标题栏显示当前时间和日期的完整代码
- JS实现网页标题栏显示当前时间和日期的完整代码
- JS (Javascript)取当前日期、时间的代码
- JS 取当前日期、时间的代码
- js获得当前日期和时间的代码
- 把时间戳转换为日期格式的js代码
- HTML显示日期时间代码 - [js 特效代码]
- 把时间戳转换为日期格式的js代码
- 用js实现页面显示当前日期和时间的代码
- js动态显示当前日期,时间和星期代码
- JS 取当前日期、时间的代码
- JS代码获取当前日期时支持IE,不兼容FF和chrome,解决这个问题,我们需要把获取时间的getYear()函数换成getFullYear()
- JS (Javascript)取当前日期、时间的代码及javascript日期比较