php随笔6-thinkphp OA系统 JS 实时显示当前时间
不多说,直入主题:
JS。
// JavaScript Document function showtime() { var today,hour,second,minute,year,month,date; var strDate ; today=new Date(); var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December"); var n_day = today.getDay(); switch (n_day) { case 0:{ strDate = "星期天" }break; case 1:{ strDate = "星期一" }break; case 2:{ strDate ="星期二" }break; case 3:{ strDate = "星期三" }break; case 4:{ strDate = "星期四" }break; case 5:{ strDate = "星期五" }break; case 6:{ strDate = "星期六" }break; case 7:{ strDate = "" }break; } hour = today.getHours(); minute =today.getMinutes(); second = today.getSeconds(); document.getElementById('time').innerHTML = monthname[today.getMonth()] + " " + today.getDate() + ", " + today.getFullYear() +" "+strDate+" " + hour + ":" + minute + ":" + second; setTimeout("showtime();", 1000); // 1000 ms(1 s) }
<span id="time"></span><script language="javascript"> showtime();</script>
搞定