suba has asked for the wisdom of the Perl Monks concerning the following question:
gives me$date_string = "Jun 03 19:49:27 2018"; $fmt = '%b %d %H:%M:%S %Y'; $time=Time::Piece->strptime( $date_string, $fmt ); print $time->strftime() ."\n";
does not do the trickmy $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";
After looking into the module itself I find that there is a flag marking the object as local. If I set it manually, I get the result I want.So, 03 Jun 2018 19:49:27 UTC
Looks ugly though, is there any better way to get there? Thanks for any hint.$date_string = "Jun 03 19:49:27 2018"; $fmt = '%b %d %H:%M:%S %Y'; $time=Time::Piece->strptime( $date_string, $fmt ); $time->[10] = 1; print $time->strftime() ."\n"; ... So, 03 Jun 2018 19:49:27 CEST
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Time::Piece and Timzone?
by hippo (Archbishop) on Jun 05, 2018 at 14:03 UTC | |
by suba (Acolyte) on Jun 05, 2018 at 14:30 UTC | |
by ikegami (Patriarch) on Jun 06, 2018 at 07:36 UTC | |
by hippo (Archbishop) on Jun 06, 2018 at 08:10 UTC | |
by suba (Acolyte) on Jun 05, 2018 at 14:11 UTC | |
by Anonymous Monk on Jun 05, 2018 at 16:39 UTC | |
|
Re: Time::Piece and Timzone?
by thanos1983 (Parson) on Jun 05, 2018 at 16:42 UTC | |
|
Re: Time::Piece and Timzone?
by ikegami (Patriarch) on Jun 06, 2018 at 07:37 UTC |