
January 22nd, 2001, 12:14 AM
|
|
All round clown
|
|
Join Date: Sep 2000
Posts: 21
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Hi,
I apologise if this is problem has been posted previously ( I am quite sure somewhere it has). I have searched, but it is impossible to comb through all the entries.
I am trying to display the current date on a web page using javascript.
The script I am using is as follows
//array with names of days of the week
var days = new Array( "Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday" );
//array with names of months
var months = new Array( "January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December" );
var today = new Date();
var sDay = days[today.getDay()];
var sMonth = months[today.getMonth()];
var date = sMonth + " " + today.getDate() + ", " + today.getYear();
document.write(sDay + ", " + date);
Unfortunately, this returns the year as 101 in Netscape. I have looked around and can see that the today.getyear is the problem, and needs to be substituted with something along the lines of getFullYear.
Any help would be appreciated.
Thanks in advance
Null
|