http://www.perlmonks.org?node_id=1033540

kehansen has asked for the wisdom of the Perl Monks concerning the following question:

I have a script to post-process a data file that contains multiple timestamps in GMT. This script is to convert the timestamps from GMT to specific timezone equivalent. My logic is to convert the timestamp to epoch seconds, determine the seconds difference between GMT and local time, subtract this from the epoch seconds, and convert this back to a local timestamp. The problem I am seeing is that in trying to get the difference between GMT & local time the returned epoch second are the same. Here is my sub-routine to get the difference.

sub getGMDelta { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $ltime = timelocal($sec,$min,$hour,$mday,$mon,$year); $gtime = timegm($sec,$min,$hour,$mday,$mon,$year); $rv = $gtime - $ltime; return($rv); }