CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
$year += 1900 is Y2K Compliant

 



Jasmine
Administrator / Moderator

Dec 20, 1999, 7:55 PM

Post #1 of 2 (875 views)
$year += 1900 is Y2K Compliant Can't Post

Fair warning... check your programs. Many programmers have changed

($sec,$min,$hour,$day,$mon,$year,$wday) = localtime(time);
$year += 1900;

to

($sec,$min,$hour,$day,$mon,$year,$wday) = localtime(time);
$year += 2000;

in their date subroutine because it looks Y2K compliant. This assumption is incorrect. The localtime function returns the number of years since 1900. In 2000, localtime will return 100, not 00. So,

$year += 1900; #equals 2000
$year += 2000; #equals 2100

A more detailed explanation is at http://www.perlarchive.com/tlc/9912/01.shtml

Cheers!

[This message has been edited by Jasmine (edited 12-20-1999).]


hydpm
User

Jul 17, 2007, 2:51 AM

Post #2 of 2 (461 views)
Re: [Jasmine] $year += 1900 is Y2K Compliant [In reply to] Can't Post

Good explanation on Y2K issue with perl...

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives