2 qq 39105509 qq_39105509 于 2017.09.16 11:05 提问

javascript显示时间 问题,求助大佬哇

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


#time { font-size: 1pc; font-weight: bolder; color: #666; background-color: #D0E8FF; vertical-align: middle; height: 200px; width: 300px; text-align: center; } function show() { var date=new getDate(); var year=date.getFullYear(); var month=date.getMonth()+1; var hour=date.getHours(); var minute=date.getMinutes(); var second=date.getSeconds(); var day=date.getDay(); document.getElementById("time").innerHTML="你好,现在是北京时间:<br>"+year+"年"+month+"月"+date+"日 "; if(hour>12) { hour=hour-12; document.getElementById("time").innerHTML=hour+":"+minute+":"+second+"PM "; } else document.getElementById("time").innerHTML=hour+":"+minute+":"+second+"AM "; switch(day) { case 0: document.getElementById("time").innerHTML="星期天<br>"; case 1: document.getElementById("time").innerHTML="星期一<br>"; case 2: document.getElementById("time").innerHTML="星期二<br>"; case 3: document.getElementById("time").innerHTML="星期三<br>"; case 4: document.getElementById("time").innerHTML="星期四<br>"; case 5: document.getElementById("time").innerHTML="星期五<br>"; case 6: document.getElementById("time").innerHTML="星期六<br>"; } ee} setInterval("show()",1000);


4个回答

Mydtudysy
Mydtudysy   2017.09.16 11:16

day=date.getDay();
年:day.getFullYear

SoulArbiter
SoulArbiter   2017.09.17 12:55

emmmm....这位大哥其实你的代码片可以截图的,这样人为增大我们的阅读难道...估计没人意愿看...

SoulArbiter
SoulArbiter   2017.09.17 12:57

关于js date( )对象的,我贴两个链接给你吧。里面讲得很详细,你的代码实在看不下去,眼睛痛....


SoulArbiter
SoulArbiter   2017.09.17 12:58
Csdn user default icon
上传中...
上传图片
插入图片