Java City 2000
Choose a Java Script Category -->       
www.jc2k.com
HOME | JAVA SCRIPTS | JAVA APPLETS | SCRIPTLETS | FREE CENTER | MIDIS | TUTORIALS | DHTML
Java City Menu

Splash Top Sites

Splash Advertisement

Recommend Us

Recommend Us To A Friend


Resources

Search 2000+ Web Hosts

Make $$$ With
Your Site

Get a FREE weekly hosting/ISP newsletter

Advertising

FreeLinks.com

Hostindex.com

Join Mailing List


Powered by ListBot

Tutorials - Fixing Java Scripts For Year 2000

Alright, I'm sure we're all pretty much sick of hearing about Y2K all the time. Yes, it's coming up; but SO WHAT!?! Well, this article is intended for those webmasters who are sick of hearing about Y2K and want to do some action so that their site is compliant with that "dreaded" year.

If you have a Javascript on your page that measures time in any way, it may not be Y2K compliant. Here is a simple thing that you can do to make it that way. Check your javascript code and see if these words appear anywhere

something.getYear();

If it appears anywhere, your javascript is not Y2K compliant. To make it Y2K complaint you will need to do a couple things to the code. First, change the text where you spotted the phrase to

something.getFullYear();

Now, look around the code and see if you see one of these two phrases also

something.getYear() - 96; (or some other 2-digit number)

or....

96 - something.getYear(); (or some other 2-digit number)

If you saw one of those two phrases, this is what you will need to do now. Add 1900 to the 2-digit number and change to the getFullYear() function. If the 2-digit number was 96, you would change it to 1996. That's it, now your javascript is Y2K compliant!

What these changes do:
The getYear() call is for the 2-digit year. This is used to simplify programming, but needs to be changed every 100 years (naturally). You'll probably see in the code something like getYear() - 96. This is perfectly logical code which takes the current year (99) and subtracts 96 to it so it gets 3 years since 1996. However, in 2000, the 2-digit year will be 00. That means if the code getYear() - 96 were still in place in the year 2000, the javascript would generate the answer -96, which is not what you're looking for. Changing the code to the getFullYear() call is for the 4-digit year. Thus, you can add 1900 to your year variable and use the getFullYear() call so your javascript will be compliant until the year 10,000.

Of course, Netscape and Microsoft will have to change the code by then, but I don't think we'll be here to worry about that ;->.

Found At: Uncanny Programming

 

 
www.jc2k.com
WEBMASTER E-ZINE | E-MAIL - feedback | HELP | HOST INDEX | MAKE $$$ WITH YOUR SITE
Java City 2000
© Java City 2000 1997-2000 - Add A Touch Of Class To Your Home!  

Java City 2000 - Java Scripts, Java Applets, HTML, Tutorials, Midi's. Sites