How can I change the date formats in Perl?

前端 未结 5 1793
生来不讨喜
生来不讨喜 2020-12-07 02:16

I just want to convert the dates from 20111230 format to 30-dec-2011.

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 02:28

    One way is to use Date::Simple:

    use warnings;
    use strict;
    use Date::Simple qw(d8);
    
    my $d = d8('20111230');
    print $d->format('%d-%b-%Y'), "\n";
    
    __END__
    
    30-Dec-2011
    

提交回复
热议问题