2012-06-16 was a Saturday, not a Friday. If you regularly get wrong weekdays in your input datetime stamps, remove the pattern %a, it will work fine without it. If you can change the output format, please use a standard format such as DateTime::Format::RFC3339 instead! This will increase interoperability.use DateTime::Format::Strptime qw(); print DateTime::Format::Strptime ->new( locale => 'en', pattern => '%a %b %d %T %Y', on_error => 'croak', )->parse_datetime('Fri Jun 16 18:04:03 2012') ->strftime('%m %d %T %Y'); # '06 16 18:04:03 2012'
use DateTime::Format::RFC3339 qw(); use DateTime::Format::Strptime qw(); print DateTime::Format::RFC3339 ->new ->format_datetime(DateTime::Format::Strptime ->new( locale => 'en', pattern => '%a %b %d %T %Y', on_error => 'croak', )->parse_datetime('Fri Jun 16 18:04:03 2012') ); # '2012-06-16T18:04:03+00:00'
In reply to Re: Conversion of Time
by daxim
in thread Conversion of Time
by PRS
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |