Re: Date is wrong in javascript

by "Comharsa" <comharsa(at)clara.net>

 Date:  Sun, 9 Jan 2000 11:02:20 -0000
 To:  <hwg-techniques(at)mail.hwg.org>
 References:  earthlink
  todo: View Thread, Original
> Good evening,
>
> How can I correct the following code so that the date does not read
1/9/100?

 You don't need to know which browser it is, just change the code to the
following.

 <SCRIPT LANGUAGE="JavaScript">
 <!--
         getTime = new Date();
         year = getYear();
         if (year<1100) year += 1900;
         document.write('<font size="2" face="geneva,arial"><B>' +
(getTime.getMonth()
 + 1) +"/"+getTime.getDate()+ "/"+ year + '</B></font><BR>');
         var Hours;
         var Mins;
         var Time;
         Hours = getTime.getHours();
         if (Hours >= 12) {
                 Time = " P.M.";
         }
         else {
                 Time = " A.M.";
         }

         if (Hours > 12) {
                 Hours -= 12;
         }

         if (Hours == 0) {
                 Hours = 12;
         }

         Mins = getTime.getMinutes();

         if (Mins < 10) {
                 Mins = "0" + Mins;
         }

         document.write('<font size="2" face="comic sans ms"><B>' +
 Hours + ":" + Mins +
 Time + '</B></font>');

//-->
 </SCRIPT>

HTH

Brian
comharsa(at)clara.net

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA