php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32270 strtotime/date behavior
Submitted: 2005-03-11 03:22 UTC Modified: 2005-06-18 16:23 UTC
Votes:11
Avg. Score:4.7 ± 0.6
Reproduced:6 of 7 (85.7%)
Same Version:5 (83.3%)
Same OS:5 (83.3%)
From: php at unfit dot org Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.0.4, 4.3.11 OS: Linux 2.4.23
Private report: No CVE-ID: None
 [2005-03-11 03:22 UTC] php at unfit dot org
Description:
------------
Negative timestamps seem to work with the date function but not the strtotime function.  This occurs on all of the Gentoo Linux boxes I am running on both kernel version 2.4.23 and 2.4.28.  I am running PHP 4.3.10 and Apache/2.0.52.


Reproduce code:
---------------
<?php
  echo date("m/d/Y H:i:s", -2145888000)."\n";
  //01/01/1902 00:00:00

  echo strtotime("Jan 1 1902")."\n";
  //-1

  echo date("m/d/Y H:i:s", -631123200)."\n";
  //01/01/1950 00:00:00

  echo strtotime("Jan 1 1950")."\n";
  //-1

  echo date("m/d/Y H:i:s", 946713600)."\n";
  //01/01/2000 00:00:00

  echo strtotime("Jan 1 2000")."\n";
  //946713600
?>

Expected result:
----------------
01/01/1902 00:00:00
-2145888000
01/01/1950 00:00:00
-631123200
01/01/2000 00:00:00
946713600


Actual result:
--------------
01/01/1902 00:00:00
-1
01/01/1950 00:00:00
-1
01/01/2000 00:00:00
946713600

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-18 16:23 UTC] derick@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed for PHP 5.1.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC