Re: Date is wrong in javascript

by David Simms <dasimms(at)sprynet.com>

 Date:  Sun, 9 Jan 2000 01:52:47 -0500
 To:  hwg-techniques(at)mail.hwg.org
 References:  earthlink
  todo: View Thread, Original
I'm thinking that this probably works okay in IE, but it is 
displaying the wrong date in Navigator. So maybe you could sniff for 
Navigator and add 1900 otherwise display as normal

hth

>Good evening,
>
>How can I correct the following code so that the date does not read 1/9/100?
>
><SCRIPT LANGUAGE="JavaScript">
><!--
>        getTime = new Date();
>        document.write('<font size="2" face="geneva,arial"><B>' + 
>(getTime.getMonth()
>+ 1) +"/"+getTime.getDate()+ "/"+getTime.getYear() + '</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>
>
>Thanks.
>-Jane

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