Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Why is my script giving the year as 19100?

by setantae (Scribe)
on Jan 28, 2000 at 05:33 UTC ( [id://2547]=perlquestion: print w/replies, xml ) Need Help??

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.

  • Comment on Why is my script giving the year as 19100?

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://2547]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found