php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40269 date_parse handles 0000-00-00 as 2000-00-00
Submitted: 2007-01-29 08:53 UTC Modified: 2014-01-25 14:24 UTC
From: cleo at anarki dot dk Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.0 OS: WindowsXP
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: cleo at anarki dot dk
New email:
PHP Version: OS:

 

 [2007-01-29 08:53 UTC] cleo at anarki dot dk
Description:
------------
MySQL uses the questionable format '0000-00-00' for a date that has not been set. A kind of null value for at date.
I fed this date into date_parse(), and got rather an unexpected result: It returns year 2000.

Reproduce code:
---------------
$d= '0000-00-00';
print_r (date_parse($d)) ;


Expected result:
----------------
Array ( [year] => 0000 [month] => 0 [day] => 0  ...

or false or null or an error of some kind.

Actual result:
--------------
Array ( [year] => 2000 [month] => 0 [day] => 0  ...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-01 23:43 UTC] jani@php.net
-Package: Feature/Change Request +Package: Date/time related
 [2014-01-25 14:24 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2014-01-25 14:24 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

This works fine in 5.2.18, 5.3.22, 5.4.x and 5.5.x.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 11:01:32 2024 UTC