"be consistent" | |
PerlMonks |
Re: String (date) to time (integer)by liverpole (Monsignor) |
on Jun 06, 2009 at 14:01 UTC ( [id://769094]=note: print w/replies, xml ) | Need Help?? |
Hi northwestdev,
Use Time::Local for the function timelocal, which is the inverse of the builtin localtime. For example:
Note that the first three arguments to timelocal above represent (respectively) the number of seconds, minutes, and hours; in your case they can be zero, as you're only interested in a one-day granularity. Update: As Corion reminds me, the month passed to timelocal needs to be zero-based, not one-based the way humans represent dates. Changing "$m" to "$m-1" in my code fixed this (thanks, Corion!). s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
In Section
Seekers of Perl Wisdom
|
|