首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

制造12小时进制的时钟

2013-12-02 
制作12小时进制的时钟bodydiv idtime stylecolor:#F00/divscript typetext/javascript s

制作12小时进制的时钟
<body> <div id="time" style="color:#F00";></div> <script type="text/javascript" src="js/time.js"></script></body>

?

function showTime(){var time = new Date();var year = time.getFullYear();var month = time.getMonth()+1;var date = time.getDate();var hh = time.getHours();var mm = time.getMinutes();var ss = time.getSeconds();var day = time.getDay();var type = "PM";if(hh<12)type="AM"if(hh<10)hh = "0"+hh;if(mm<10)mm = "0"+mm;if(ss<10)ss = "0"+ss;var week = "";switch(day){case 0:week = "星期日";break;case 1:week = "星期一";break;case 2:week = "星期二";break;case 3:week = "星期三";break;case 4:week = "星期四";break;case 5:week = "星期五";break;default:week = "星期六";break;}var html = "<h3>你好,欢迎访问贵美商城!<br />"+year+"年"+month+"月"+date+"日&nbsp;"+hh+":"+mm+":"+ss+"&nbsp;"+type+"&nbsp;"+week+"</h3>";document.getElementById("time").innerHTML=html;}window.onload = function(){var obj = setInterval("showTime()",1000);}

?

效果图:
制造12小时进制的时钟
?

个人E-mail:chaoyi77@163.com

?

?

热点排行