http://www.perlmonks.org?node_id=2547

setantae has asked for the wisdom of the Perl Monks concerning the following question: (dates and times)

Why is my script giving the year as 19100?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: Why is my script giving the year as 19100?
by heezy (Monk) on Oct 09, 2002 at 14:49 UTC

    As mentioned above, the value returned is the number of years since 1900. To find the 'real' year you need to add 1900 to the year returned by localtime.

    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(ti +me); $year = $year + 1900;

    Hope that helps

    M

    K.I.S.S

Re: Why is my script giving the year as 19100?
by setantae (Scribe) on Jan 28, 2000 at 05:34 UTC
    Because you're concatenating the result you got from localtime() with 19.
    localtime() returns the number of years since 1900, which is 100 at the moment.
    (Well, yeah, it returns a load of other stuff too, but I'll get to that another time).

    See the perlfunc:localtime node.