Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Does Perl have a year 2000 problem? Is Perl Y2K compliant?

by faq_monk (Initiate)
on Oct 08, 1999 at 00:20 UTC ( #589=perlfaq nodetype: print w/replies, xml ) Need Help??

Current Perl documentation can be found at

Here is our local, out-dated (pre-5.6) version:

Short answer: No, Perl does not have a Year 2000 problem. Yes, Perl is Y2K compliant. The programmers you're hired to use it, however, probably are not.

Long answer: Perl is just as Y2K compliant as your pencil--no more, and no less. The date and time functions supplied with perl (gmtime and localtime) supply adequate information to determine the year well beyond 2000 (2038 is when trouble strikes for 32-bit machines). The year returned by these functions when used in an array context is the year minus 1900. For years between 1910 and 1999 this happens to be a 2-digit decimal number. To avoid the year 2000 problem simply do not treat the year as a 2-digit number. It isn't.

When gmtime() and localtime() are used in scalar context they return a timestamp string that contains a fully-expanded year. For example, $timestamp = gmtime(1005613200) sets $timestamp to ``Tue Nov 13 01:00:00 2001''. There's no year 2000 problem here.

That doesn't mean that Perl can't be used to create non-Y2K compliant programs. It can. But so can your pencil. It's the fault of the user, not the language. At the risk of inflaming the NRA: ``Perl doesn't break Y2K, people do.'' See for a longer exposition.

Log In?

What's my password?
Create A New User
[SuicideJunkie]: spies would want a system to not be able to audit.
[erix]: spies should use a type-writer, no power needed, no auditable
[erix]: if all else fails, eat the paper
[erix]: a few years ago there was suddenly the news that the Kremlin was using typewriters again. Heard nothing about it afterward
[erix]: (maybe that means it worked)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2017-06-23 20:19 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (555 votes). Check out past polls.