in reply to Convert GMT date and time to local time
Does it have to be Date::Manip? I prefer DateTime, it has excellent time zone handling and everything else regarding date/time handling, also via add-ons like for example DateTime::Format::Strptime.
use warnings; use strict; use DateTime; use DateTime::Format::Strptime; my $strp = DateTime::Format::Strptime->new(on_error=>'croak', pattern => '%Y-%m-%d-%H:%M:%S %Z'); my $datestr = "2016-07-30-15:30:00 GMT"; my $dt = $strp->parse_datetime($datestr); print $dt->strftime('%Y-%m-%d-%H:%M:%S %Z'), "\n"; $dt->set_time_zone('America/Los_Angeles'); print $dt->strftime('%Y-%m-%d-%H:%M:%S %Z'), "\n"; __END__ 2016-07-30-15:30:00 UTC 2016-07-30-08:30:00 PDT
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Convert GMT date and time to local time
by Anonymous Monk on Sep 13, 2017 at 10:11 UTC |