Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Converting datetime string to valid localtime value (seconds)

by halley (Prior)
on May 16, 2003 at 18:40 UTC ( #258732=note: print w/ replies, xml ) Need Help??

in reply to Converting datetime string to valid localtime value (seconds)

Off by a day? Without digging deeper, I recall that the arrays returned by localtime() have a month from 0 to 11, inexplicably, but a day from 1 to ~31. Whether that's what you're hitting, I thought I'd take this opportunity to gripe about such fencepost errors.

[ e d @ h a l l e y . c c ]

Comment on Re: Converting datetime string to valid localtime value (seconds)
Replies are listed 'Best First'.
Re: Re: Converting datetime string to valid localtime value (seconds)
by vladb (Vicar) on May 16, 2003 at 18:51 UTC
    How do array indexes come into play when I'm only looking at this line of code:
    localtime(Date_SecsSince1970($mon{$mon}, $d, $y, $h, $mn, $s))
    If the values of $mon{$mon}, $d, $y, $h are valid (5, 15, 2003, 01 respectively), why the resulting datetime string returned by localtime() is in fact "Wed May 14 18:05:02 2003"?

    Please note that I do not force localtime() to return datetime values in array format. What this line of code (and accompanying output) seem to indicate is that the Date_SecsSince1970() method miscalculates seconds or, to state it otherwise, calculates seconds in a way that is incompatible with how the time() method does it.

    Afterall, print "time string: " . localtime(time()) would produce valid result.

    "We've all heard that a million monkeys banging on a million typewriters will eventually reproduce
    the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true."

    Robert Wilensky, University of California

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2015-12-01 03:53 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (792 votes), past polls