yyyymmddhhmmss to YYYY-MM-DD hh:mm:ss in perl?

前端 未结 3 1621
眼角桃花
眼角桃花 2021-01-06 08:48

What is the best way to convert yyyymmddhhmmss to YYYY-MM-DD hh:mm:ss and back in perl?

for example: 20130218165601 to 2013-02-18 16:56:01 and back? (can https://met

3条回答
  •  醉梦人生
    2021-01-06 09:21

    Quick solution with sprintf.

    my $date = sprintf "%s%s-%s-%s %s:%s:%s", $string =~ /(..)/g;
    

    And back:

    my $foo = join '', $date =~ /\d+/g;
    

提交回复
热议问题