...

View Full Version : get year not working Google Chrome



low tech
01-16-2012, 12:42 AM
Hello all

I have this code to write the year which works fine in ie ff but apparantly is not working in google chrome.

I don't have chrome and so can't check can anybody tell me why chrome has an issue with it? What should I change to make it chrome compliant:-)


In ie ff it displays 2012 correctly but in chrome i'm told it is showing 112 ro something like that.




<script type="text/javascript">var curdate = new Date(); var year = curdate.getYear(); document.write(year)</script>


any help very much appreciated

LT

xelawho
01-16-2012, 01:12 AM
hello lowtech,

I am surprised you were getting the right year in firefox - I got 112 there as well. I note that getYear() is deprecated, but I assume it gives you how many years it has been since 1900.

or something useful like that.

I think getFullYear() is what you are after :thumbsup:

low tech
01-16-2012, 01:20 AM
Hi xelawho

Thanks for that --- didn't know getYear was deprecated.

Yeh ff was showing ok and usually for me if ff is ok and ie doesn't complain then i'm good hahaha

will change it later today

much appreciated

LT:thumbsup:

felgall
01-16-2012, 02:13 AM
getYear returns different results in different browsers because it isn't Y2K compliant. No attempt was made to make it compliant because it was deprecated with getFullYear replacing it in the late 1990s.

low tech
01-16-2012, 02:45 AM
Hi felgal

Thanks for the info

I had that code lying around and I just used it while recently updating my site ---- it seemed fine in ie ff but was but was reported as not working correctly.

LT

felgall
01-16-2012, 09:06 AM
Unfortunately there's lots of obsolete JavaScript still around - and even people still teaching how to write JavaScript for the 1990s (without telling their students that what they are teaching was outdated 10 or more years ago).

low tech
01-16-2012, 11:48 AM
Hi all

Updated site -- all's well now:-)

ie ff and chrome

many thanks

LT

Philip M
01-16-2012, 01:11 PM
Unfortunately there's lots of obsolete JavaScript still around - and even people still teaching how to write JavaScript for the 1990s (without telling their students that what they are teaching was outdated 10 or more years ago).

Stephen - tell us about it! :D Almost every week students post assignments and code here which are wildly out of date. I wonder how long teachers of law or medicine would survive if they taught such obsolete stuff? I have the idea that some people who teach Javascript are the rejects from other subjects and have been downgraded to RE or IT!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum