1. No Profile Picture
    All round clown
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Rep Power

    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",
    "Saturday" );

    //array with names of months
    var months = new Array( "January",
    "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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 1999
    Rep Power
    I don't understand what the problem is.

    Just use the date.getFullYear() function. If you're using date.getYear() you need to add 1900 to it, so it is correctly returning 101. Note that getFullYear() only works with browsers that support JavaScript 1.3 or greater.

IMN logo majestic logo threadwatch logo seochat tools logo