in reply to Time::Piece and Timzone?

Your second option works fine for me (using Time::Piece 1.31_04):

$ perl -MTime::Piece my $date_string = "Jun 03 19:49:27 2018 +0200"; my $fmt = '%b %d %H:%M:%S %Y %z'; my $time=Time::Piece->strptime( $date_string, $fmt ); print $time->strftime() ."\n"; Sun, 03 Jun 2018 17:49:27 UTC

So I guess the strptime() implementation in your O/S differs from mine. Which O/S are you using?

Replies are listed 'Best First'.
Re^2: Time::Piece and Timzone?
by suba (Acolyte) on Jun 05, 2018 at 14:30 UTC
    You are correct, code runs just fine on a OS-X machine.
    Had a look at the changelog for Time::Piece, 1.15 seems to be too old...

    1.16 - Implement %z for the internal implementation of strptime().

    Thanks for the help
Re^2: Time::Piece and Timzone?
by ikegami (Patriarch) on Jun 06, 2018 at 07:36 UTC

      Yes, it does now. However in the somewhat older versions (prior to 1.17) such as the one used by suba on an RHEL6 box, that wasn't the case.

Re^2: Time::Piece and Timzone?
by suba (Acolyte) on Jun 05, 2018 at 14:11 UTC
    Linux (RedHat 6), perl5.10.1, Time::Piece v1.15
      Red Hat 6 is also old.