可能重複:
Simple way to format date如何改變1996-08-29T00:00:00.0000Z日期格式17日 - 2013年的Perl
如何改變「1996- 08-29T00:00:00.0000Z「的日期格式爲perl中的日期格式爲2013年5月17日
需要幫助。非常感謝您
可能重複:
Simple way to format date如何改變1996-08-29T00:00:00.0000Z日期格式17日 - 2013年的Perl
如何改變「1996- 08-29T00:00:00.0000Z「的日期格式爲perl中的日期格式爲2013年5月17日
需要幫助。非常感謝您
use DateTime::Format::RFC3339 qw();
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
一個輕量級的解決方案:
use POSIX qw(strftime);
my ($y, $m, $d) = '1996-08-29T00:00:00.0000Z' =~ /^(....)-(..)-(..)/s;
say strftime('%d-%b-%Y', 0,0,0, $d,$m-1,$y-1900); # 29-Aug-1996
加上'$ dt-> add(days => 6105)'去2013年5月17日。 – simbabque
@simbabque,他從未說過「1996-08-29T00:00:00.0000Z」應該給「2013年5月17日」 。 '「1996-08-29T00:00:00.0000Z」'是格式,而不是輸入。 – ikegami
@ikegami,是正確的..我只需要格式..感謝所有現在我測試它..但面臨此錯誤「找不到字符串終止符」EOP「在EOF之前的任何地方在/ usr/lib/perl5/site_perl /5.8.8/i386-linux-thread-multi/List/MoreUtils.pm line 1.「任何人都知道如何解決它? – Zann
進進出出。與您的問題有幾乎17年的相關日期差異?此外,如果您「需要幫助」,則必須顯示您需要幫助的部分。請顯示一些代碼。 –
歡迎來到SO。請看看http://stackoverflow.com/questions/how-to-ask – simbabque
不是重複。 – ikegami