Converting timestamps in Perl containing timezone

  Kiến thức lập trình

I need to convert following timestamp containing ms and timezone to yyyy-mm-dd format:

my $created = "2024-07-02T11:20:11.000+0200";
my $test2 = Time::Piece->strptime($created},"%Y%m%dT%H:%M:%S.%z")->strftime("%Y-%m-%d");

but I’m getting an error:

Error parsing time at /usr/local/lib/perl5/5.18.1/x86_64-linux/Time/Piece.pm line 469.

Would anybody show me a correct way how to do that?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT