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

    Join Date
    Sep 2000
    Posts
    21
    Rep 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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 1999
    Location
    Seattle
    Posts
    133
    Rep Power
    16
    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