I am trying to convert a date/time GMT 0 to GMT -6 in Perl.
For example, a DHCP Server lease time is in the following format:
2010/02/18 23:48:37
I am trying to convert that time to the Localtime zone (GMT -6) but need it to honor Daylight savings time.
The script below may be overkill, but I am not sure how to proceed from here. (Any suggestions would be awsome).
my $TIMESTART;
$TIMESTART = "2010/02/18 23:48:37";
$TIMESTART =~ s/\//-/g;
use DateTime;
use DateTime::TimeZone;
use DateTime::Format::MySQL;
my $dt = DateTime::Format::MySQL->parse_datetime($TIMESTART);
my $tz = DateTime::TimeZone->new( name => 'America/Chicago' );
print $tz->offset_for_datetime($dt) . "\n";
It will output the following lines:
2010-02-18T23:48:37
-21600
I need to be able to add -21600 to the date to get the local time zone of GMT -6 but I am not sure how to approch this.