Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have 2 linux machines that need to run a Perl script and access a database. The date (as reported by the date and date -u commands) is correct (within a couple of minutes), but returning epoch from Perl has a 1 hour difference resulting in having on one machine UTC epoch-timestamp and on the other the wanted CET.

date on A:

Tue Dec 11 13:34:09 CET 2012

date on B:

Tue Dec 11 13:33:20 CET 2012

The script uses Time::HiRes and gathering the localtime->epoch to generate a date. I build a minimalistic following script to output the behaviour:

#/usr/bin/perl
#
use Time::HiRes qw(time);
use Time::Piece;
#
my $date = Time::Piece->strptime(localtime->epoch,"%s");
print "$date->datetime"."\n";
print $date->tzoffset."\n";
print $date->epoch."\n";

Output Machine A:

Tue Dec 11 12:35:43 2012->datetime 
0 
1355229343

Output Machine B:

Tue Dec 11 13:34:25 2012->datetime 
0 
1355232865

So as you see something must be wrong, probably with timezone or something similar. But I don't know where to look and what to configure as date itself outputs the correct time.

share|improve this question
    
Why don't you just just adjust the time within BIOS? This isn't a "time zone" problem. This is clear by the fact they are only different by 1 minute and 11 seconds. –  Ramhound Dec 11 '12 at 13:02
    
Sorry, but I guess either you didn't read the question carefully or I didn't make it clear enough: Look at the epoch timestamps -> those are the ones that differ over an hour but no timezone offset is set on any machine. –  Stefan Dec 11 '12 at 13:04
    
I read the question and the times are 1 minute 11 seconds different and set to CET. Based on the output of the perl script I assume there is a configuration difference. –  Ramhound Dec 11 '12 at 13:17
    
The output of date may differ only with minutes and this is ok. But the output of the perl script differs more than 1 hour. This may be a configuration difference - I just don't know where to look what is wrong :-(. 'locale' is the same on both machines for every type. –  Stefan Dec 11 '12 at 13:23
    
Does date -u return correct values on both machines (within a few minutes)? –  David Schwartz Dec 11 '12 at 13:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.