Discrepancy in Time?

J

Jason Quek

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
(e-mail address removed)
 
J

John Strauss

On Wed, 30 Jul 2003 09:50:13 GMT
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
 
C

Cat

Jason said:
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;
 
C

Cat

Jason said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top