Quickly getting to YYYY-mm-dd HH:MM:SS in Perl

后端 未结 9 1052
礼貌的吻别
礼貌的吻别 2021-01-30 02:30

When writing Perl scripts I frequently find the need to obtain the current time represented as a string formatted as YYYY-mm-dd HH:MM:SS (say 2009-11-29 14:28

9条回答
  •  花落未央
    2021-01-30 02:45

    Try this:

    use POSIX qw/strftime/;
    print strftime('%Y-%m-%d',localtime);
    

    the strftime method does the job effectively for me. Very simple and efficient.


提交回复
热议问题