Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Re: Time to secondsby chipmunk (Parson) |
on Nov 16, 2001 at 08:02 UTC ( [id://125757]=note: print w/replies, xml ) | Need Help?? |
The result of timelocal will depend on the local time zone. For example, when I ran your code it printed 18123 because I'm at GMT-0500. Of course, that can be avoided by using gmtime insead. The following code prints the expected 3723:
Unfortunately, even that's not a complete solution, because the epoch is not Jan 1, 1970 on all platforms. On the Macintosh, for example, it's Jan 1, 1904, and the output is 2082830523. There's still a way to do it with timelocal, though: The choice of year is relatively arbitrary, but note that you mustn't pick a time of year that will be affected by daylight savings. So, you can solve this problem using Time::Local, you just have to be careful about how you do it.
In Section
Seekers of Perl Wisdom
|
|