Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > getYear() returns correct year local, but wrong year online

Reply
Thread Tools

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

 
 
Veerle
Guest
Posts: n/a
 
      08-19-2003
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
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      08-19-2003
(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.'
 
Reply With Quote
 
 
 
 
niceguy
Guest
Posts: n/a
 
      08-20-2003
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=htt...%7Evv991306%2F
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
simulation result is correct but synthesis result is not correct J.Ram VHDL 7 12-03-2008 01:26 PM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
Uploaded File Empty but in correct folder with correct name froil Perl Misc 12 03-02-2006 01:21 PM
Date object's getDay returns wrong date for Feb in any leap year David Woodward Javascript 5 02-02-2004 08:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57