<!-- 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>