perl - formatting DateTime output

前端 未结 3 1532
北荒
北荒 2021-01-05 02:13

How do I convert my return using DateTime from:

This is my date:2011-11-26T20:11:06 to This is my date:20111126

Using this existin

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-05 02:51

    Just add ->ymd("") on the second line. The parameter "" is the separator, which you chose to be an empty string.

    use DateTime qw();
    my $dt3 = DateTime->now->subtract(days => 1)->ymd("");
    print "This is my date:$dt3\n"
    

提交回复
热议问题