Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: The function localtime(time) returns wrong month . How to overcome this problem ??

by Corion (Pope)
on Feb 09, 2006 at 09:56 UTC ( #529035=note: print w/ replies, xml ) Need Help??


in reply to The function localtime(time) returns wrong month . How to overcome this problem ??

I wonder if you'd care to suggest how we could improve the documentation for localtime to make it more obvious how to solve your problem. Currently the docs say this:

... $mday is the day of the month, and $mon is the month itself, in the range 0..11 with 0 indicating January and 11 indicating December.

If you're formatting dates for outputting to the user, let me recommend a proper date formatting tool, like POSIX::strftime or DateTime or Date::Calc.

If all you need is the number of the month, how about just adding 1 to the number?


Comment on Re: The function localtime(time) returns wrong month . How to overcome this problem ??
Select or Download Code
Re^2: The function localtime(time) returns wrong month . How to overcome this problem ??
by nevyn (Monk) on Feb 23, 2006 at 21:28 UTC

    Change it from...

    $mon is the month itself, in the range 0..11 with 0 indicating January and 11 indicating December.

    ...to...

    $mon is the month offset, in the range 0..11 with 0 indicating January and 11 indicating December.

    ...as the former implies that $mon is the number of the month which people might assume starts at 1 (and stop reading). But my guess is that anyone who has a problem hasn't read the current docs. (but, hey at least they don't just assume tm_year is the last two digits nowadays).

    --
    James Antill

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-12-29 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (185 votes), past polls