Getting 2 different epoch values when running UnixData (ParseData) in perl

62 Views Asked by At
use Date::Manip;

my $jobStartdate = "2024-3-20 15:46:00";
my $jobStartD = ParseDate("$jobStartdate");
my $jobStartEpoch = UnixDate($jobStartD,"%s");

When running the above code on 2 different machine, getting 2 different values of $jobStartEpoch. Why is it so? How can I correct the setting on the machines so that the values are same?

1

There are 1 best solutions below

4
choroba On

The output depends on the time zone setting.

$ TZ=UTC ./script.pl
1710949560

$ TZ=Asia/Singapore ./script.pl
1710920760

I just added the following lines to the script:

use feature 'say';
say $jobStartEpoch;