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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cm at fuf dot de
New email:
PHP Version: OS:

 

 [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: Wed Apr 24 16:01:31 2024 UTC