如何更改 Perl 中的日期格式? [英] How can I change the date formats in Perl?
本文介绍了如何更改 Perl 中的日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想将日期从 20111230
格式转换为 30-dec-2011
.
I just want to convert the dates from 20111230
format to 30-dec-2011
.
推荐答案
为了与 TMTOWTDI 保持一致,您可以使用 时间::片断
In keeping with TMTOWTDI, you can use Time::Piece
#!/usr/bin/env perl
use strict;
use warnings;
use Time::Piece;
my $t = Time::Piece->strptime("20111230", "%Y%m%d");
print $t->strftime("%d-%b-%Y
");
这篇关于如何更改 Perl 中的日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文