How can I change the date formats in Perl?

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

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

5条回答
  •  悲哀的现实
    2020-12-07 02:40

    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\n");
    

提交回复
热议问题