<script type="text/javascript">
function date(){
//arguments JS自带的变量
this.length = arguments.length;
for(var i= 0; i < this.length; i ++){
this[i] = date.arguments[i];
}
}
function displaytime(){
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
//0-2 午夜 2-5 凌晨 5-9 早上 9-12 上午 12-14 中午 14-18 下午 18-24 晚上
var ampm = "上午";
if (h >= 0 && h < 2) ampm = "午夜";
if (h >= 2 && h < 5) ampm = "凌晨";
if (h >= 5 && h < 9) ampm = "早上";
if (h >= 9 && h < 12) ampm = "上午";
if (h >= 12 && h < 14) ampm = "中午";
if (h >= 14 && h < 18) ampm = "下午";
if (h >= 18) ampm = "晚上";
//12小时制
if (h >12) h -= 12;
//补0
if (m < 10) m = "0" + m;
//补0
if (s < 10) s = "0" + s;
var time = ampm + h + ":" + m + ":" + s;
//年月日和星期
var day = new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
var ymd = d.getYear() + "年" + (d.getMonth() + 1) + "月" + d.getDate() + "日" + day[d.getDay()];
//取得显示位置
var tiemarea = document.getElementById("timearea");
timearea.innerHTML = ymd + " " + time;
setTimeout("displaytime()",1000);
}
</script>
function date(){
//arguments JS自带的变量
this.length = arguments.length;
for(var i= 0; i < this.length; i ++){
this[i] = date.arguments[i];
}
}
function displaytime(){
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
//0-2 午夜 2-5 凌晨 5-9 早上 9-12 上午 12-14 中午 14-18 下午 18-24 晚上
var ampm = "上午";
if (h >= 0 && h < 2) ampm = "午夜";
if (h >= 2 && h < 5) ampm = "凌晨";
if (h >= 5 && h < 9) ampm = "早上";
if (h >= 9 && h < 12) ampm = "上午";
if (h >= 12 && h < 14) ampm = "中午";
if (h >= 14 && h < 18) ampm = "下午";
if (h >= 18) ampm = "晚上";
//12小时制
if (h >12) h -= 12;
//补0
if (m < 10) m = "0" + m;
//补0
if (s < 10) s = "0" + s;
var time = ampm + h + ":" + m + ":" + s;
//年月日和星期
var day = new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
var ymd = d.getYear() + "年" + (d.getMonth() + 1) + "月" + d.getDate() + "日" + day[d.getDay()];
//取得显示位置
var tiemarea = document.getElementById("timearea");
timearea.innerHTML = ymd + " " + time;
setTimeout("displaytime()",1000);
}
</script>
<body onload="displaytime();">
<div id="timearea" style="color:White; font-size:12px; text-align:center;">
</div>
</div>
二:
<div style="FONT-SIZE: 12px; COLOR: white; TEXT-ALIGN: center" id="jnkc">
<SCRIPT>setInterval("jnkc.innerHTML=new Date().toLocaleString();",1000); </SCRIPT>
</div>
<SCRIPT>setInterval("jnkc.innerHTML=new Date().toLocaleString();",1000); </SCRIPT>
</div>
三
<style type="text/css">
.content{text-align:center;}
#linkweb {500px;margin:100px auto 0;border:#f00 solid 1px;padding:20px;font-size:18px;font-weight:700}
#linkweb1 {500px;margin:150px auto 0;border:#f0f solid 1px;padding:20px;font-size:18px;font-weight:700}
</style>
<div class="content">
<div id="linkweb">正在加载</div>
<div id="linkweb1">正在加载 </div>
</div>
<script>setInterval("document.getElementById('linkweb').innerHTML='当前按时间是:'+new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);</script>
<script>setInterval("document.getElementById('linkweb1').innerHTML='当前按时间是:'+new Date().toLocaleString().replace(' ',' 星期'+'日一二三四五六'.charAt(new Date().getDay())+' ');",1000);</script>
.content{text-align:center;}
#linkweb {500px;margin:100px auto 0;border:#f00 solid 1px;padding:20px;font-size:18px;font-weight:700}
#linkweb1 {500px;margin:150px auto 0;border:#f0f solid 1px;padding:20px;font-size:18px;font-weight:700}
</style>
<div class="content">
<div id="linkweb">正在加载</div>
<div id="linkweb1">正在加载 </div>
</div>
<script>setInterval("document.getElementById('linkweb').innerHTML='当前按时间是:'+new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);</script>
<script>setInterval("document.getElementById('linkweb1').innerHTML='当前按时间是:'+new Date().toLocaleString().replace(' ',' 星期'+'日一二三四五六'.charAt(new Date().getDay())+' ');",1000);</script>