Bug #53221 [Bgs]: Date since epoch is incorrect

From: Date: Tue, 02 Nov 2010 07:54:31 +0000
Subject: Bug #53221 [Bgs]: Date since epoch is incorrect
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155702@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53221&edit=1

 ID:                 53221
 User updated by:    c dot d dot claxton at googlemail dot com
 Reported by:        c dot d dot claxton at googlemail dot com
 Summary:            Date since epoch is incorrect
 Status:             Bogus
 Type:               Bug
 Package:            Date/time related
 Operating System:   Windows 7
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

Many thanks for finding the reason for the problem.


Previous Comments:
------------------------------------------------------------------------
[2010-11-01 22:39:04] rasmus@php.net

It is just a 32-bit signed integer overflow.

Note that even 64-bit Windows still uses 32-bit integers.  

Platforms with 64-bit integers won't overflow and don't have this
problem.  Not 
much we can do about this.

------------------------------------------------------------------------
[2010-11-01 22:18:00] c dot d dot claxton at googlemail dot com

Description:
------------
Checked the number of seconds since the epoch using the code shown in
the 'Test 
script' section below. There is a discrepancy when number of seconds = 
10000000000 in that time goes backwards, i.e. 1973 to 2001 to 2014 to
2008.

Number of seconds since epoch = 1, date = 1 January 1970 01:00:01 
Number of seconds since epoch = 10, date = 1 January 1970 01:00:10 
Number of seconds since epoch = 100, date = 1 January 1970 01:01:40 
Number of seconds since epoch = 1000, date = 1 January 1970 01:16:40 
Number of seconds since epoch = 10000, date = 1 January 1970 03:46:40 
Number of seconds since epoch = 100000, date = 2 January 1970 04:46:40 
Number of seconds since epoch = 1000000, date = 12 January 1970 14:46:40

Number of seconds since epoch = 10000000, date = 26 April 1970 18:46:40

Number of seconds since epoch = 100000000, date = 3 March 1973 10:46:40

Number of seconds since epoch = 1000000000, date = 9 September 2001
03:46:40 
Number of seconds since epoch = 10000000000, date = 7 September 2014
06:50:08 
Number of seconds since epoch = 100000000000, date = 11 July 2008
06:56:32 

Test script:
---------------
<?php
  for ($i=0; $i<12; $i++) {
    $numberOfSecondsSinceEpoch = pow(10,$i); 
    $date = date("j F Y H:i:s", $numberOfSecondsSinceEpoch);
    echo "Number of seconds since epoch = $numberOfSecondsSinceEpoch,
date = $date <br />";
  } 
?>



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53221&edit=1


Thread (3 messages)

« previous php.bugs (#155702) next »