If your page requires a more sophisticated way to display the time, you'll love this script. It will write in the format, 'XX Till Hour'. It's ten past three in the afternoon, for example.
Add the below code to the <body> section of your page:
<scriptlanguage="javascript"type="text/javascript"> /* Visit http://www.yaldex.com/
for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin function
doFormalTime(){ var
myTime =newDate(); var
myHour =
myTime.getHours(); var
myMinutes =
myTime.getMinutes(); var
ampm =" in the morning.";
// gets nearest 5 minutes myMin =
myMinutes -(myMinutes
%5); // closer to next 5 minutes, go
to next if(myMinutes
%5>2)
myMin +=5;
vartext="It is now about ";
switch(myMin){ case0:
myHour--;break; case5:text+="five after ";
myHour--;break; case10:text+="ten after ";
myHour--;break; case15:text+="quarter after ";
myHour--;break; case20:text+="twenty after ";
myHour--;break; case25:text+="twenty-five after ";
myHour--;break; case30:text+="half past ";
myHour--;break; case35:text+="twenty-five till ";break; case40:text+="twenty till ";break; case45:text+="quarter till ";break; case50:text+="ten till ";break; case55:text+="five till ";break; case60:break;
} if(myHour
<1)
myHour++;// fix for noon/midnight if(ampm
=="pm"){ ampm =(myHour
>=4)?" in the evening.":" in the afternoon.";
} text+=
Hour[myHour]+
ampm; returntext;
} document.write('<b>'+doFormalTime()+'</b>'); // End --> </script>