|
The
Source |
|
<SCRIPT language="JavaScript"> function
startclock() var
nhours=thetime.getHours(); <!--AM or PM --> if
(nhours>=12) <!-- Current Hour not in Military Time --> if
(nhours>=13) if
(nsecn<10) if
(nmins<10) <!-- Day as in
Monday, Tuesday, etc --> nmonth+=1; if
((nyear>99) && (nyear<2000)) <!-- The Final Output for the
Broswer document.clockform.clockspot.value= nhours+": "+nmins+": "+nsecn+" "+AorP+" "+nday+", "+nmonth+"/"+ntoday+"/"+nyear; setTimeout('startclock()',1000); } //--> </SCRIPT> |
|
|
Explanation:
Well it's pretty much the same as the other one, but now I added a couple of new functions, to display the actual date and current time.
The variable nyear gives the number of years into the current century- the last two numbers of the year such as 98 or 99. One problem- the dreaded Y2K problem. In IE5+, the date actually goes to 4 numbers, to 2000. In NS 4.6 the date flips to 100- not zero! I tested the code below, and it works for these two browsers, though I did not check it with older versions- but those may have other Y2K bugs to worry about. So, if the year comes back as 99, I added a 19 in front. If it is between 99 and 2000, I added 1900 to it (100+1900=2000) so NS would work with it. IE just gives back 2000 so if it is more than 2000 it can be left alone.
if (nyear<=99) nyear= "19"+nyear; if ((nyear>99) && (nyear<2000)) nyear+=1900;
Well that's about it.