php.net |  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
Description:
------------
---
From manual page: http://www.php.net/book.datetime
---

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:
----------------
2000

Actual result:
--------------
1999

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-08 15:05 UTC] derick@php.net
-Status: Open +Status: Bogus
 [2011-04-08 15:05 UTC] derick@php.net
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 
http://bugs.php.net/bug.php?id=53662 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