<!-- Saved From url=http://www.knowsky.com/JS --> <!-- Web Design bbs url=http://www.knowsky.com/bbs--> <!--要完成此效果需要兩個步驟 第一步:把如下代碼加入到<head>區域中--> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function doFormalTime() { var myTime = new Date(); var myHour = myTime.getHours(); var myMinutes = myTime.getMinutes(); var ampm = "早上"; if (myHour >= 12) { myHour -= 12; // change to PM ampm = "pm"; } Hour = new Array( "一點", "二點", "三點", "四點", "五點", "六點", "七點", "八點", "九點", "十點", "十一點", "十二點"); myMin = myMinutes - (myMinutes % 5); if (myMinutes % 5 > 2) myMin += 5; var text = "估計現在的時間為: "; switch(myMin) { case 0 : myHour--; break; case 5 : text += "零五分"; myHour--; break; case 10 : text += "十分"; myHour--; break; case 15 : text += "十五分"; myHour--; break; case 20 : text += "二十分"; myHour--; break; case 25 : text += "二十五"; myHour--; break; case 30 : text += "三十分"; myHour--; break; case 35 : text += "差二十五分"; break; case 40 : text += "差二十分"; break; case 45 : text += "差十五分"; break; case 50 : text += "差十分"; break; case 55 : text += "差五分"; break; case 60 : break; } if (myHour < 1) myHour++; if (ampm == "pm") { ampm = (myHour >= 4) ? "晚上" : "中午"; } text += ampm + Hour[myHour]; return text; } // End --> </script> <!--第二步:把如下代碼加入到<body>區域中--> <script> document.write(doFormalTime()); </script>