I have a set of time stamps that are set in UTC. Here is a small example:

2011-08-09 03:33:11 2011-07-09 00:27:23 2011-07-25 22:24:08

I need to convert these to my systems local time. So I need to first acquire the local time zone, then convert the above values from UTC to whatever is revealed from finding out the system time zone.

I have tried using DateTime. I have a simple script written that does "stuff", but not what I need.

#!/usr/bin/perl -w use strict; use warnings; use DateTime; my $dt = DateTime->now(time_zone => 'America/North_Dakota/Center'); #$dt->set_time_zone('Europe/Guernsey'); my $time = $dt->strftime('%F %T'); print "$time\n";

What this this does is prints the local time:

2011-11-10 10:58:00

What is the best method to convert $utctime (2011-08-09 03:33:11) to a local time zone based on what time zone if found out by acquiring the system timezone, converting it to (2011-08-08 22:33:11)? This should be the safest way to avoid the whole daylight savings time issue.? The above script doesn't do it, but I think it's a good start.


In reply to time stamp store in $utctime needs converting to local time zone by TheBigAmbulance

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.