# Discrepancy in Time?

Discussion in 'Perl Misc' started by Jason Quek, Jul 30, 2003.

1. ### Jason QuekGuest

When I convert "26 Oct 2003" to epoch seconds,

#-----------------------------------------------------------------
use Time::Local;
\$from = timelocal(0, 0, 0, 26, 9, 2003);
# \$from == 1067140800;
#-----------------------------------------------------------------

When I convert "27 Oct 2003" to epoch seconds,

#-----------------------------------------------------------------
use Time::Local;
\$from = timelocal(0, 0, 0, 26, 9, 2003);
# \$to == 1067230800;
#-----------------------------------------------------------------

#-----------------------------------------------------------------
\$difference = \$to - \$from;
# \$difference == 90000;
#-----------------------------------------------------------------

Shouldn't the difference between the 26th and 27th be 86400
(60*60/24)? Where did the extra 1 hour come from?

Does anybody know why this happens?

Regards,

Jason Quek

Jason Quek, Jul 30, 2003

2. ### John StraussGuest

On Wed, 30 Jul 2003 09:50:13 GMT
(Jason Quek) wrote:
>
> When I convert "26 Oct 2003" to epoch seconds,
>
> #-----------------------------------------------------------------
> use Time::Local;
> \$from = timelocal(0, 0, 0, 26, 9, 2003);
> # \$from == 1067140800;
> #-----------------------------------------------------------------
>
> When I convert "27 Oct 2003" to epoch seconds,
>
> #-----------------------------------------------------------------
> use Time::Local;
> \$from = timelocal(0, 0, 0, 26, 9, 2003);
> # \$to == 1067230800;
> #-----------------------------------------------------------------
>
> #-----------------------------------------------------------------
> \$difference = \$to - \$from;
> # \$difference == 90000;
> #-----------------------------------------------------------------
>
> Shouldn't the difference between the 26th and 27th be 86400
> (60*60/24)? Where did the extra 1 hour come from?
>
>
> Does anybody know why this happens?
>
>

sounds like DST ends. try timegm() instead of timelocal().

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drop the .thetenant to get me via mail

John Strauss, Jul 30, 2003

3. ### CatGuest

Jason Quek wrote:
>
> When I convert "26 Oct 2003" to epoch seconds,
>
> #-----------------------------------------------------------------
> use Time::Local;
> \$from = timelocal(0, 0, 0, 26, 9, 2003);
> # \$from == 1067140800;
> #-----------------------------------------------------------------
>
> When I convert "27 Oct 2003" to epoch seconds,
>
> #-----------------------------------------------------------------
> use Time::Local;
> \$from = timelocal(0, 0, 0, 26, 9, 2003);
> # \$to == 1067230800;
> #-----------------------------------------------------------------
>
> #-----------------------------------------------------------------
> \$difference = \$to - \$from;
> # \$difference == 90000;
> #-----------------------------------------------------------------
>
> Shouldn't the difference between the 26th and 27th be 86400
> (60*60/24)? Where did the extra 1 hour come from?
>
> Does anybody know why this happens?
>

You should copy and paste... that way we can see the _exact_ code.

When I run the program below, I get
From: 1064498400
To: 1064584800
Difference: 86400

#!/bin/perl
use strict;
use warnings;
use diagnostics;

use Time::Local;

my \$from = timelocal(0, 0, 0, 26, 8, 103);
my \$to = timelocal(0, 0, 0, 27, 8, 103);
my \$difference = \$to - \$from;

Cat, Jul 30, 2003
4. ### CatGuest

Jason Quek wrote:
>
> When I convert "26 Oct 2003" to epoch seconds,
>
> #-----------------------------------------------------------------
> use Time::Local;
> \$from = timelocal(0, 0, 0, 26, 9, 2003);
> # \$from == 1067140800;
> #-----------------------------------------------------------------
>
> When I convert "27 Oct 2003" to epoch seconds,
>
> #-----------------------------------------------------------------
> use Time::Local;
> \$from = timelocal(0, 0, 0, 26, 9, 2003);
> # \$to == 1067230800;
> #-----------------------------------------------------------------
>
> #-----------------------------------------------------------------
> \$difference = \$to - \$from;
> # \$difference == 90000;
> #-----------------------------------------------------------------
>
> Shouldn't the difference between the 26th and 27th be 86400
> (60*60/24)? Where did the extra 1 hour come from?
>
> Does anybody know why this happens?
>

Daylight savings

Cat, Jul 30, 2003