TheBigAmbulance has asked for the wisdom of the Perl Monks concerning the following question:
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:00What 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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: time stamp store in $utctime needs converting to local time zone
by martell (Hermit) on Nov 10, 2011 at 19:56 UTC | |
|
Re: time stamp store in $utctime needs converting to local time zone
by jethro (Monsignor) on Nov 10, 2011 at 18:21 UTC |