Results 1 to 5 of 5

Thread: Javascript code for current day

  1. #1
    Veteran False Truth is making a name for themselves False Truth is making a name for themselves False Truth's Avatar
    Join Date
    Nov 2004
    Location
    Chicago
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript code for current day

    I want to know the right javascript code for the current date....

    I used.....

    <SCRIPT LANGUAGE="JAVASCRIPT">
    <!--Hide from old browsers
    var tNow=new Date()
    var tlocDate=tNow.toLocaleString()
    var tDate=tlocDate.substring(0, 10)
    document.write("<H3><CENTER>"+tDate+" </CENTER></H3>")
    //-->
    </SCRIPT>


    It's supposed to display " Sunday, June 05, 2005...."

    But all it displays it "Sunday,"

    I want to know what code am I missing or what I did wrong....

    This signature is within the limits upheld by the forum rules. Unless the rules change, do not remove.

  2. #2
    Legendary Otaku Sinistra may be famous one day Sinistra may be famous one day Sinistra's Avatar
    Join Date
    Oct 2004
    Location
    Radford VA
    Posts
    2,528
    Thanks
    0
    Thanked 3 Times in 2 Posts
    try
    Code:
    <SCRIPT LANGUAGE="JavaScript1.2">
    var months=new Array(13);
    months[1]="January";
    months[2]="February";
    months[3]="March";
    months[4]="April";
    months[5]="May";
    months[6]="June";
    months[7]="July";
    months[8]="August";
    months[9]="September";
    months[10]="October";
    months[11]="November";
    months[12]="December";
    var time=new Date();
    var lmonth=months[time.getMonth() + 1];
    var date=time.getDate();
    var year=time.getYear();
    if (year < 2000)    // Y2K Fix, Isaac Powell
    year = year + 1900; // http://onyx.idbsu.edu/~ipowell
    document.write("<center>" + lmonth + " ");
    document.write(date + ", " + year + "</center>");
    // End -->
    </SCRIPT>
    </CENTER>

  3. #3
    Lost in the ethernet dragonrider2004 may be famous one day dragonrider2004 may be famous one day dragonrider2004's Avatar
    Join Date
    Oct 2004
    Location
    127.0.0.1
    Posts
    729
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you need to add the rest of the date. what the code does is get the day of the week not the date.

    Student: "Umm sensei, the question on the board is wrong."
    Teacher "SHAAAADD UP!"

  4. #4
    Veteran False Truth is making a name for themselves False Truth is making a name for themselves False Truth's Avatar
    Join Date
    Nov 2004
    Location
    Chicago
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Lord Katsuhito and dragonrider2004, problem solved. You may close the thread if you wish.

    This signature is within the limits upheld by the forum rules. Unless the rules change, do not remove.

  5. #5
    Legendary Otaku Sinistra may be famous one day Sinistra may be famous one day Sinistra's Avatar
    Join Date
    Oct 2004
    Location
    Radford VA
    Posts
    2,528
    Thanks
    0
    Thanked 3 Times in 2 Posts
    Problem fixed topic closed ^_^

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts