use DateTime::Format::RFC3339;
my $format = DateTime::Format::RFC3339->new();
my $dt = $format->parse_datetime('1996-08-29T00:00:00.0000Z');
say $dt->strftime('%d-%b-%Y'); # 29-Aug-1996
当我运行此脚本时,我收到以下错误:
缺少右侧卷曲或方括号 /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DateTime/Locale/Base.pm 第1行,在行尾语法错误处 /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DateTime/Locale/Base.pm 第1行,在EOF
除了base.pm
从cpan http://cpansearch.perl.org/src/DROLSKY/DateTime-Locale-0.45/lib/DateTime/Locale/Base.pm
答案 0 :(得分:1)
current version of DateTime是0.75, DateTime-Format-RFC3339是1.0.5。
要正确安装模块,请参阅What's the easiest way to install a missing Perl module?。
答案 1 :(得分:-2)
我将DateTime用于更复杂的东西。对于简单的解析/格式,我这样做:
use warnings;
use strict;
use Date::Parse;
use Date::Format;
my $dt = str2time('1996-08-29T00:00:00.0000Z');
print time2str('%d-%b-%Y', $dt);