[sf-perl] Date manipulation question
Bill Moseley
moseley at hank.org
Sat Jul 5 07:04:30 PDT 2008
On Sat, Jul 05, 2008 at 08:48:20AM -0500, Richard Reina wrote:
> I have a date that is a string such as: Thu Jul 3 17:43:45 2008
> and need to convert it to epoch seconds. I am scowering my perl books
> and the web but cannot find a function to help me do this. Does
> anyone know how this can be done?
perldoc Time::Local is one way.
But, I like to have all my dates in DateTime objects. There's more than
one parser that will work.
$ perl -MDateTime::Format::DateParse -le 'print DateTime::Format::DateParse->parse_datetime( "Thu Jul 3 17:43:45 2008")->epoch'
1215132225
$ perl -MDateTime::Format::HTTP -le 'print DateTime::Format::HTTP->parse_datetime( "Thu Jul 3 17:43:45 2008")->epoch'
1215107025
--
Bill Moseley
moseley at hank.org
Sent from my iMutt
More information about the SanFrancisco-pm
mailing list