php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55252 On 64 bit strtotime() mishandles all-zero timestamps
Submitted: 2011-07-20 11:35 UTC Modified: 2011-07-21 14:42 UTC
From: cm at fuf dot de Assigned:
Status: Duplicate Package: Date/time related
PHP Version: 5.3.6 OS: Linux 2.6.38 amd64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
49 - 16 = ?
Subscribe to this entry?

 
 [2011-07-20 11:35 UTC] cm at fuf dot de
Description:
------------
The behavior of strtotime() on 64 bit machines (see below) for all-zero timestamps is undesirable.  On 32 bit machines the function outputs NULL for a string input "0000-00-00 00:00", on 64 bit machines it yields -62169987600.  This is undesirable, as the all-zero timestamp is not a valid date ("00" is not a month). On 64 bit systems strtotime() should return NULL for "0000-00-00 00:00".


Test script:
---------------
/* Linux ubuntu64-vbox 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 
 * 2011 x86_64 x86_64 x86_64 GNU/Linux
 * PHP 5.3.6-6~dotdeb.1 with Suhosin-Patch (cli) (built: Apr  3 2011 16:36:05) 
 */

<?php
  echo strtotime("0000-00-00 00:00");
?>

Actual result:
--------------
-62169987600

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-21 14:42 UTC] aharvey@php.net
-Status: Open +Status: Duplicate
 [2011-07-21 14:42 UTC] aharvey@php.net
This is completely valid, per strtotime()'s documented behaviour: invalid 
components within date strings are conformed as best as they can be, and in that 
case, you've basically asked for the last day in November in the year -1 
(effectively 2 BC).

Closing duplicate, as this has previously been dealt with in bug #53662.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 06:01:35 2024 UTC