SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: year problem

  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    year problem

    dont u just love netscape??
    im not very fimilar to javascript, so any help would be great

    in Ie, this works fine, but in netscape, the year part screws up.. it returns 201 or something wierd like that

    whats goin on??

    PHP Code:
    <Script language=javascript type="text/javascript">
    currentDate = new Date
    currentMonth 
    = new Array ("January""February""March""April""May""June""July""August""September""October""November""December")
    document.write("<img src=\"" currentMonth[currentDate.getMonth()].toLowerCase() + "_" currentDate.getDate() + "_" currentDate.getYear() + "_small.jpg\">")
    </Script> 

    thanx

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi:

    Y2K bug
    year = currentDate.getYear()
    year = (year < 1000) ? year+1900 : year;

    or you can use:

    year = currentDate.getFullYear()

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


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
  •