getYear() returns correct year local, but wrong year online

Discussion in 'Javascript' started by Veerle, Aug 19, 2003.

  1. Veerle

    Veerle Guest

    Hello,

    I have made a first version of the frontpage of my new homepage. I use
    the small javascript

    <script type="text/javascript">
    var modDate = new Date(document.lastModified);
    var day = modDate.getDate();
    var month = modDate.getMonth()+1;
    var year = modDate.getYear();
    var s = "Deze pagina werd laatst aangepast op ";
    s += ((day < 10)?"0"+day:day) + "/";
    s += ((month < 10)?"0"+month:month) + "/";
    s += year;
    s += ".";
    document.writeln(s);
    </script>

    to print the date on which the page was last modified. When I look at
    the page when it resides on my hard disk, then the date is correct:
    19/08/2003. But when I put that same page online at the webspace
    assigned to me by my internet provider, then the date turns into
    19/08/2036. So the year is completely wrong!

    I use Internet Explorer 6.0. The url of the online page is
    http://home.scarlet.be/~vv991306/temp_homepage/

    Any idea what I'm doing wrong here? Or is the date on the server set
    wrong and is that what's causing my problem?

    Thanks,
    Veerle
     
    Veerle, Aug 19, 2003
    #1
    1. Advertising

  2. (Veerle) writes:

    > var modDate = new Date(document.lastModified);


    Try reading <URL:http://jibbering.com/faq/#FAQ4_30>
    /L
    --
    Lasse Reichstein Nielsen -
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Aug 19, 2003
    #2
    1. Advertising

  3. Veerle

    niceguy Guest

    On Tue, 19 Aug 2003 18:39:13 +0100, Veerle wrote
    (in message <>):

    > Hello,
    >
    > I have made a first version of the frontpage of my new homepage. I use
    > the small javascript
    >
    > <script type="text/javascript">
    > var modDate = new Date(document.lastModified);
    > var day = modDate.getDate();
    > var month = modDate.getMonth()+1;
    > var year = modDate.getYear();
    > var s = "Deze pagina werd laatst aangepast op ";
    > s += ((day < 10)?"0"+day:day) + "/";
    > s += ((month < 10)?"0"+month:month) + "/";
    > s += year;
    > s += ".";
    > document.writeln(s);
    > </script>
    >
    > to print the date on which the page was last modified. When I look at
    > the page when it resides on my hard disk, then the date is correct:
    > 19/08/2003. But when I put that same page online at the webspace
    > assigned to me by my internet provider, then the date turns into
    > 19/08/2036. So the year is completely wrong!
    >
    > I use Internet Explorer 6.0. The url of the online page is
    > http://home.scarlet.be/~vv991306/temp_homepage/
    >
    > Any idea what I'm doing wrong here? Or is the date on the server set
    > wrong and is that what's causing my problem?
    >
    > Thanks,
    > Veerle


    Visit
    http://www.samspade.org/t/safe?u=http://home.scarlet.be/~vv991306/
    temp_homepage%2F

    Your server date is set to 2036 - simple as that. Knowing it, you can just
    subtract 33 from your getYear

    Hope that helps
     
    niceguy, Aug 20, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Nitulescu
    Replies:
    2
    Views:
    593
    Alex Nitulescu
    Feb 25, 2005
  2. J.Ram
    Replies:
    7
    Views:
    680
  3. David Woodward
    Replies:
    5
    Views:
    444
    Dr John Stockton
    Feb 2, 2004
  4. What-a-Tool

    .getYear function work in IE only?

    What-a-Tool, Mar 14, 2005, in forum: Javascript
    Replies:
    5
    Views:
    197
    Dr John Stockton
    Mar 15, 2005
  5. Paul E. Schoen

    Different in IE and Firefox: now.getYear()+1900

    Paul E. Schoen, Sep 28, 2007, in forum: Javascript
    Replies:
    7
    Views:
    156
    Dr J R Stockton
    Sep 29, 2007
Loading...

Share This Page