Practical Perl wrote:
Hello,lists,
Please see these two lines' output:
[$ perl -Mstrict -MTime::Local -le 'print timelocal(0,0,0,31,8,2006)'
Day '31' out of range 1..30 at -e line 1
$ perl -Mstrict -MTime::Local -le 'print timelocal(0,0,0,31,7,2006)'
1156953600
I translate the time of '2006-7-31 00:00:00' to unix timestamp,it's
successful.
But when I translate the time of '2006-8-31 00:00:00' to unix timestamp,it
said '31 out of range'.
I'm so faint that August doesn't have 31th day?Please tell me why this
happen and how to resolve it.
Thank you very much.
I believe it is because the months are 0-indexed (0-11), so
timelocal(0,0,0,31,8,2006) is 2006-7-31 *not* 2006-8-31.
It also say so in the documentation.
perldoc Time::Local
Hope it helps.
--
Flemming Greve Skovengaard The killer's breed or the Demon's seed,
a.k.a Greven, TuxPower The glamour, the fortune, the pain,
<[EMAIL PROTECTED]> Go to war again, blood is freedom's stain,
4011.74 BogoMIPS Don't you pray for my soul anymore.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>