Simple way to format date

前端 未结 4 1287
悲哀的现实
悲哀的现实 2021-01-22 12:54

I wrote a perl script to get datetime. It do work but I do wonder if there any easier way to format date as output.

#!/usr/bin/perl
use DateTime;

my $dt                 


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-01-22 13:49

    For re-formatting dates, as noted, there is the POSIX core module. You would be remiss not to look at the core module Time::Piece too, which not only delivers strftime() but also strptime() to provide very flexible date/time parsing. Time::Piece appeared in Perl core in 5.9.5.

提交回复
热议问题