FrankRalphBob FrankRalphBob - 9 months ago 36
Perl Question

How to get the Time->epoch to be from a certain timezone

We are trying to use utime to update files to a certain timestamp. To do this we are taking the string version of the timestamp, turning it into a "time object" and then using the epoch method to get the epoch to update the time file.

my $yyyymmddhhmmss; # variable holding string version of time. example: 20150512:150632
my $fileTime = Time::Piece->strptime($yyyymmddhhmmss, '%Y%m%d:%H%M%S');
utime $fileTime->epoch, $fileTime->epoch, $outfile;

However, it is setting the file timestamp to UTC, which is different than the time zone we are in. Besides manually adding the extra seconds, is there another way to have the epoch push out the seconds for our time zone?


Nowhere do you specify that $yyyymmddhhmmss is a localtime.


Time::Piece->strptime($yyyymmddhhmmss, '%Y%m%d:%H%M%S')


localtime->strptime($yyyymmddhhmmss, '%Y%m%d:%H%M%S')