in reply to Can Date::Manip parse a unix timestamp ?

For unix timestamps, just prepend "epoch ". This is well documented.

$ perl -wE 'use Date::Manip; say UnixDate("epoch 1264108407", "%O\n")' + 2010-01-21T22:13:27

If you have Date::Manip 6, you can also parse that format with Date::Manip directly, though not with the default parsing rules, you have to give the format explicitly.

$ perl -wE 'use Date::Manip 6.0; my $d = Date::Manip::Date->new; $d->p +arse_format("%a %b %d %T %Y %z", "Thu Jan 21 17:13:27 2010 -0400"); s +ay $d->printf("%O");' 2010-01-21T17:13:27

Replies are listed 'Best First'.
Re^2: Can Date::Manip parse a unix timestamp?
by SBECK (Chaplain) on May 05, 2010 at 15:31 UTC

    Just to put in my opinion... I'd like to see Date::Manip able to parse the date "Thu Jan 21 17:13:27 2010 -0400" directly without having to resort to the parse_format function... so I'll add it to my todo list. The parse_format function is good for catching formats I hadn't anticipated, but this one is common enough I should be able to parse it directly.

    It's an unusual format in that the time portion and date portion are intermingled. Date::Manip 6 parses the time and date portions separately, so this format is not a trivial date format to add unfortunately.

      For reference, the date format "%a %b %d %T %Y" (without timezone) came up again in a later question Perl date calculation and formatting. Date::Manip can parse such dates since version 6.31 (2012-03-01).