This does the trick:
use 5.010; use DateTime::Format::ISO8601; say DateTime::Format::ISO8601 -> parse_datetime('2012-02-25T18:48:34.835-05:00') -> strftime('%F %T');
However, note that you're dropping the time zone altogether! Unless you know that all the Atom entries have been posted from the same time zone, this is a bad idea.
An entry dated 2012-02-25T12:00:00+12:00 was written a full day earlier than one at 2012-02-25T12:00:00-12:00, yet using the conversion above, they'd both get formatted as 2012-02-25 12:00:00.
To solve that you could normalise them all to the same time zone before formatting. UTC is the time zone most commonly used for that purpose.
use 5.010; use DateTime::Format::ISO8601; say DateTime::Format::ISO8601 -> parse_datetime('2012-02-25T18:48:34.835-05:00') -> set_time_zone('UTC') -> strftime('%F %T');
In reply to Re: Format XML Atom DateTime
by tobyink
in thread Format XML Atom DateTime
by omegaweaponZ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |