发布网友 发布时间:2022-04-28 04:02
共1个回答
热心网友 时间:2022-04-28 05:31
<script>
function get_time()
{
var date=new Date();
var year="",month="",day="",week="",hour="",minute="",second="";
year=date.getFullYear();
month=add_zero(date.getMonth()+1);
day=add_zero(date.getDate());
week=date.getDay();
switch (date.getDay()) {
case 0:val="周日";break
case 1:val="周一";break
case 2:val="周二";break
case 3:val="周三";break
case 4:val="周四";break
case 5:val="周五";break
case 6:val="周六";break
}
hour=add_zero(date.getHours());
minute=add_zero(date.getMinutes());
second=add_zero(date.getSeconds());
document.getElementById("timetable").innerHTML=" "+year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second+" "+val;
}
function add_zero(temp)
{
if(temp<10) return "0"+temp;
else return temp;
}
setInterval("get_time()",1000);
</script>
其实用js实现很简单,何必用PHP,你把上面的插入到PHP中就行了,,
在html中直接<div id="timetable"></div>
就可以了
亲!!请采纳谢谢!!