|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54493 Dates stored as yyyy-00-00 in MySQL are returned as the previous year
Submitted: 2011-04-08 13:10 UTC Modified: 2011-04-08 16:21 UTC
From: john at designstage dot co dot uk Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS:
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.
Block user comment
Status: Assign to:
Bug Type:
From: john at designstage dot co dot uk
New email:
PHP Version: OS:


 [2011-04-08 13:10 UTC] john at designstage dot co dot uk
From manual page:

If a year is saved as a MySQL date without months or days being set - in the 
format yyyy-00-00 - when it's returned using DateTime the year before results. So 
2000-00-00 is returned with the value of the year set to 1999.

Test script:
<?php  $date = '2000-00-00';
$date = new DateTime($date);
echo $date->format('Y'); ?>

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-08 15:05 UTC]
-Status: Open +Status: Bogus
 [2011-04-08 15:05 UTC]
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Duplicate of #53662
 [2011-04-08 16:21 UTC] john at designstage dot co dot uk
Apologies - didn't realise that the problem reported in resulted in this as well.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 14 12:01:29 2024 UTC