Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Ontario, Canada
    Posts
    104
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need date script that works in NS

    I'm preparing my online resume and have run into a glitch. I want to include the date only -- not the time -- on my cover letter page but every date JavaScript I've tried buggers up in NS 4.7 (don't know about NS 6 as I don't have it installed). While the date shows up perfectly in IE, the year always gets jumbled in NS. For example:

    Saturday, July 6, 102

    or

    Saturday, July 6, 19102

    Does anyone have a date only script that works in NS? Any help would be greatly appreciated. I can hardly expect to get the job if I can't get the date right on the first page!

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    basically,,,,netscape looks at the date a different way

    one way to do it is this

    if(Year<2000){Year+=1900;}

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Ontario, Canada
    Posts
    104
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi A1ien51 and thanks for the quick response. Your solution seems simple, but NS still doesn't like it. This is the most simple script I was trying and it would seem to fit perfectly with your solution:

    <SCRIPT type="text/javascript" language="JavaScript1.2">
    var mydate=new Date()
    var year=mydate.getYear()
    if (year<2000)
    year="19"+year
    var day=mydate.getDay()
    var month=mydate.getMonth()
    var daym=mydate.getDate()
    var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
    var montharray=new Array("January","February","March","April","May","June","July","August","September","October","Novem ber","December")
    document.write("<font color='162040' face='Arial' size=2>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"<\/font>")
    </SCRIPT

    I inserted {Year+=1900;} immediately after the code in red but that doesn't do the trick in NS. The date shows up as:

    Sunday, July 7, 102

    BTW, you need a space between the if (Year or else you a "year not defined" error. But that's neither here nor there because with or without the space, it still doesn't work in NS.

    I got this brainstorm of an idea while looking at your code and thought, "I don't need to worry about years less than 2000 since I want the current year, which is greater than 2000." So I removed this part of the script:

    if (year<2000)
    year="19"+year


    And while it worked in IE, NS didn't like that solution either! It still showed the year as 102

    Brainstorm #2: I decided to remove all references to the year and enter the year as simple text:

    <SCRIPT type="text/javascript" language="JavaScript1.2">
    var mydate=new Date()
    var day=mydate.getDay()
    var month=mydate.getMonth()
    var daym=mydate.getDate()
    var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
    var montharray=new Array("January","February","March","April","May","June","July","August","September","October","Novem ber","December")
    document.write("<font color='162040' face='Arial' size=2>"+dayarray[day]+", "+montharray[month]+" "+daym+", 2002<\/font>")
    </SCRIPT>

    And this worked in IE, but NS didn't like that solution either! It still showed the year as 102

    <sigh> It's a simple little date code. How can NS bugger up something so simple? (rhetorical question -- I know why!) I would say to heck with the date appearing correctly in NS but it would be my luck that the employer who wants to hire me is using NS !!!!

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Here is the code you need


    <SCRIPT type="text/javascript" language="JavaScript1.2">
    var mydate=new Date()
    var year=mydate.getYear()
    if(year<2000){year+=1900;}
    var day=mydate.getDay()
    var month=mydate.getMonth()
    var daym=mydate.getDate()
    var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
    var montharray=new Array("January","February","March","April","May","June","July","August","September","October","Novem ber","December")
    document.write("<font color='162040' face='Arial' size=2>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"<\/font>")
    </SCRIPT>

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Location
    Ontario, Canada
    Posts
    104
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yep, that does the trick! The difference one line of code makes! Thank you very much.


  •  

    Posting Permissions

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