in reply to Converting dates with Date:Format
For completeness: DateTime:
(Note that your input has no timezone info, so you can't use %Z to print the timezone with accuracy. Also note that you have two spaces in your input, so the solution reflects that.)
Or, more succinctly as a one-liner:use DateTime::Format::Strptime; my $formatter = DateTime::Format::Strptime->new(pattern => "%F %T"); my $dt_obj = $formatter->parse_datetime("2008-11-03 19:03:44"); my $datetime = $dt_obj->strftime("%a, %d %b %Y %T EST");
Output:perl -ML -E'say DateTime::Format::Strptime->new(pattern => "%F %T")-> parse_datetime("2008-11-03 19:03:44")->strftime("%a, +%d %b %Y %T EST"); '
Mon, 03 Nov 2008 19:03:44 EST
Hope this helps!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Converting dates with Date:Format
by haukex (Archbishop) on Jan 10, 2017 at 14:32 UTC | |
by 1nickt (Canon) on Jan 10, 2017 at 14:57 UTC | |
by haukex (Archbishop) on Jan 10, 2017 at 15:10 UTC |