Web Analytics Made Easy -
StatCounter Need date script that works in NS - CodingForum

Announcement

Collapse
No announcement yet.

Need date script that works in NS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    basically,,,,netscape looks at the date a different way

    one way to do it is this

    if(Year<2000){Year+=1900;}
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

    Comment


    • #3
      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 !!!!

      Comment


      • #4
        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>
        Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

        Comment


        • #5
          Yep, that does the trick! The difference one line of code makes! Thank you very much.

          Comment

          Working...
          X