in reply to UTC Time Conversion
use POSIX qw/strftime/; use Date::Parse; $ENV{TZ} = "UTC"; my $utc_date_str = "2003-05-06 02:09:00 UTC"; my $epoch_secs = str2time($utc_date_str); $ENV{TZ} = "Canada/Atlantic"; # set TZ to local my $local_date_str = strftime("%Y-%m-%d %T %Z", localtime($epoch_secs) + ); $ENV{TZ} = "UTC"; # restore TZ to UTC print "$local_date_str\n"; -- OUTPUT: 2003-05-05 23:09:00 ADT
You might also want to have a look at the other Date:: modules. Most of them are small and fast (except for Date::Manip :-), and the odds are that no matter what you have to do in terms of date manipulation, there already exists a module to solve your problem (at least in part).
|
|---|