title: How I can I convert timezones in Perl?
body: <p>I am trying to convert a date/time GMT 0 to GMT -6 in Perl.</p>
  
  <p>For example, a DHCP Server lease time is in the following format: </p>
  
  <blockquote>
    <p>2010/02/18 23:48:37</p>
  </blockquote>
  
  <p>I am trying to convert that time to the Localtime zone (GMT -6) but need it to honor Daylight savings time.</p>
  
  <p>The script below may be overkill, but I am not sure how to proceed from here.  (Any suggestions would be awsome).</p>
  
  <pre><code>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-&gt;parse_datetime($TIMESTART);
  
  my $tz = DateTime::TimeZone-&gt;new( name =&gt; 'America/Chicago' );
  
  print $tz-&gt;offset_for_datetime($dt) . "\n";
  </code></pre>
  
  <p>It will output the following lines:</p>
  
  <blockquote>
    <p>2010-02-18T23:48:37<br>
    -21600</p>
  </blockquote>
  
  <p>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.</p>