|  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
 [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: Sat Jun 22 09:01:29 2024 UTC