Simple way to format date

前端 未结 4 1313
悲哀的现实
悲哀的现实 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:43

    Sure, use POSIX module:

    The POSIX module permits you to access all (or nearly all) the standard POSIX 1003.1 identifiers.

    Example:

    use POSIX;
    print POSIX::strftime('%d-%m-%Y %H:%M:%S', localtime());
    

提交回复
热议问题