How to parse a string into a DateTime object in Perl?

前端 未结 4 1585
旧时难觅i
旧时难觅i 2020-12-03 02:23

I know about the DateTime Perl module, and many of the DateTime::Format:: modules to parse specific kinds of date/time formats. However given some examples of d

4条回答
  •  一整个雨季
    2020-12-03 03:11

    I tend to use Time::Piece simply because it's part of the standard Perl module set since version 5.10.

    You can't beat it's ability to parse date strings.

    my $time = Time::Piece->strptime(
          "October 28, 2011 9:00 PM PDT",
          "%B %d, %Y %r %Z");
    

提交回复
热议问题