JS如下:
var tmpDate = new Date();
var myArray=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
date = tmpDate.getDate();
month= tmpDate.getMonth()+1;
year= tmpDate.getFullYear();
weekday=tmpDate.getDay();
mdate=year+"年"+month+"月"+date+"日"+" "+myArray[weekday];
function show5(){
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="上午"
if (hours>12){dn="下午";hours=hours-12;}
if (hours==0){hours=12;}
if (minutes<=9){minutes="0"+minutes;}
if (seconds<=9){seconds="0"+seconds;}
myclock=dn+" "+hours+":"+minutes+":"+seconds;
document.getElementById("time").innerHTML=mdate+" "+myclock;
setTimeout("show5()",1000)
}
页面如下:
<span id="time"> </span>
- 本文标题: JS 控制显示日期,时,分,秒,时实显示
- 文章分类:【JQuery/JavaScript】
- 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.