我想将2015-09-11T04:00:00转换为
Time::Piece对象.我试过了:
my $date = "2015-09-11T04:00:00"; my $t = Time::Piece->strptime($date,'%FT%T'); print $t->strftime('%F %T');
解决方法
你有没有考虑过放弃Time :: Piece for others?例如,DateTime就像它在锡上说的那样:
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