Re: Date is wrong in javascript

by "The Lion's Cub" <lionscub(at)elknet.net>

 Date:  Sun, 9 Jan 2000 01:31:12 -0600
 To:  <cbirds(at)earthlink.net>,
<hwg-techniques(at)mail.hwg.org>
 References:  earthlink
  todo: View Thread, Original
Try this one, with some work I think the Y2K patch could be made to work
with your script

<SCRIPT TYPE="text/JavaScript">

<!-- Begin
var months=new Array(13);
months[1]="Jan";
months[2]="Feb";
months[3]="Mar";
months[4]="Apr";
months[5]="May";
months[6]="Jun";
months[7]="Jul";
months[8]="Aug";
months[9]="Sep";
months[10]="Oct";
months[11]="Nov";
months[12]="Dec";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();

// Y2K Fix by Isaac Powell
// http://onyx.idbsu.edu/~ipowell

if ((navigator.appName == "Microsoft Internet Explorer") && (year < 2000))
year="19" + year;
if (navigator.appName == "Netscape")
year=1900 + year;
document.write(" " + lmonth + " ");
document.write(date + "<br>" + year + " ");
// End
// -->
</script>


----- Original Message -----
From: "Jane" <cbirds(at)earthlink.net>
To: <hwg-techniques(at)mail.hwg.org>
Sent: January 08, 2000 07:10 PM
Subject: Date is wrong in javascript


> 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>');
>
> file://-->
> </SCRIPT>
>
> Thanks.
> -Jane

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