<body>
<p id="date"></p>
</body>
<script>
function fun(){
var date =new Date();
var year = date.getFullYear();
var month = date.getMonth();
var day = date.getDate();
var hour = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var week = date.getDay();
if(week==1){
week="一";
}if(week==2){
week="二";
}
if(week==3){
week="三";
}
if(week==4){
week="四";
}
if(week==5){
week="五";
}
if(week==6){
week="六";
}
if(week==7){
week="日";
}
var am="";
if(hour>=0 && hour<=12){
am = "AM";
}else{
am = "PM"
}
document.getElementById("date").innerHTML=year+"年"+month+"月"+day+"日"+" "+hour+":"+minutes+":"+seconds+" "+am+" 星期"+week;
}
onload = function(){
setInterval("fun()",100);
}
</script>
用JavaScript显示系统时间
最新推荐文章于 2024-09-13 13:33:58 发布