Discrepancy in Time?

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

  1. Jason Quek

    Jason Quek Guest

    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
    #1
    1. Advertising

  2. Jason Quek

    John Strauss Guest

    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
    #2
    1. Advertising

  3. Jason Quek

    Cat Guest

    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
    #3
  4. Jason Quek

    Cat Guest

    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
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand P Paralkar

    Discrepancy in CLB Usage Report

    Anand P Paralkar, Jul 2, 2003, in forum: VHDL
    Replies:
    0
    Views:
    1,064
    Anand P Paralkar
    Jul 2, 2003
  2. Gopal
    Replies:
    4
    Views:
    403
    Dario
    Oct 30, 2003
  3. Paul Carey

    Static Access Discrepancy?

    Paul Carey, Jan 16, 2004, in forum: Java
    Replies:
    1
    Views:
    402
    Jon Skeet
    Jan 16, 2004
  4. Eric
    Replies:
    0
    Views:
    387
  5. Karl Uppiano

    Java Time Discrepancy

    Karl Uppiano, Jul 8, 2007, in forum: Java
    Replies:
    2
    Views:
    439
    Karl Uppiano
    Jul 8, 2007
Loading...

Share This Page