Why do I get "Error Processing Time" when I use the format string "% FT% T" with Time :: Piece-> strptime?
I am trying to convert 2015-09-11T04:00:00to a Time :: Piece object . I tried:
my $date = "2015-09-11T04:00:00";
my $t = Time::Piece->strptime($date, '%FT%T');
print $t->strftime('%F %T');
But I get it Error Parsing Time. I think this is because I'm looking %FT%T, and this causes problems due to the interval. How can i fix this?
Have you considered from time to time: Piece for something else? DateTime , for example, does what it says on tin:
use strict;
use warnings;
use DateTime::Format::Strptime;
my $date = '2015-09-11T04:00:00';
my $strp = DateTime::Format::Strptime->new(pattern => '%FT%T');
my $dt = $strp->parse_datetime($date);
print $dt->datetime; # prints 2015-09-11T04:00:00