Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17

Thread: Date

  1. #1
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    Could somebody please tell me what is wrong with this date i wrote?
    Code:
    now = new Date();
    
    day = now.getDay();
    if (day == 0){day = "Sunday"}
    if (day == 1){day = "Monday"}
    if (day == 2){day = "Tuesday"}
    if (day == 3){day = "Wednesday"}
    if (day == 4){day = "Thursday"}
    if (day == 5){day = "Friday"}
    if (day == 6){day = "Saturday"}
    
    month = now.getMonth();
    if (month == 0){month = "January"}
    if (month == 1){month = "February"}
    if (month == 2){month = "March"}
    if (month == 3){month = "April"}
    if (month == 4){month = "May"}
    if (month == 5){month = "June"}
    if (month == 6){month = "July"}
    if (month == 7){month = "August"}
    if (month == 8){month = "September"}
    if (month == 9){month = "October"}
    if (month == 10){month = "November"}
    if (month == 11){month = "December"}
    
    date = now.getDate();
    if (date == 1){date + "st"}
    if (date == 2){date + "nd"}
    if (date == 3){date + "rd"}
    if (3 < date < 21){date + "th"}
    if (date == 21){date + "st"}
    if (date == 22){date + "nd"}
    if (date == 23){date + "rd"}
    if (23 < date < 31){date + "th")
    if (date == 31){date + "st"}
    
    year = now.getYear();
    
    date1.innerHTML = "Today is" + day + "," + date + "" + year
    JR

  2.  

  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    Shouldn't it be [minicode]date1.innerHTML = "Today is " + month + " " + day + date + ", " + year[/minicode]?

    The other thing is that innerHTML is not NS4-compliant. If you're going for NS4 compliance, you have to do [Minicode] document.date4.document.write ("Today is " + month + " " + day + date + ", " + year)[/Minicode].

    Have I mentioned today how much I hate Netscape? I'll do it now.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  4. #3
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    thanks, i hate netscape too, im glad i don't have to use it anymore

    the forum stats for netscape users will probably drop to 0% now i don't use it anymore
    JR

  5. #4
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    still doesn't work
    JR

  6. #5
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    Where's the page? Maybe seeing it will clue me in.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  7. #6
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    its my no graphics contest entry - i will post it in a new file and try it
    JR

  8. #7
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    here it is
    JR

  9. #8
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    This works...

    Here you go.

    You'll notice that I used the % (modulus) operator to get a remainder instead of a series of "if" statements for every single date. It seemed to clean it up.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  10. #9
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    thanks game
    JR

  11. #10
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    Yeah, I know, I'm great.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:24 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com