Home » Date and Time » Date » Bug #445
Date does not handle DATE_FORMAT_ISO_EXTENDED correctly
Details
| Submitted | 2003-12-17 12:16 UTC |
|---|---|
| From | mike dot carter at personalmedicaladvisor dot co dot uk |
| Assigned | pajoye |
| Status | Closed |
| Package | Date |
| PHP Version | 4.3.4 |
| OS | Redhat 9 |
| Roadmaps | (Not assigned) |
Comments
[2003-12-17 12:16 UTC] mike dot carter at personalmedicaladvisor dot co dot uk
Description:
------------
Passing in what looks like a valid DATE_FORMAT_ISO_EXTENDED format string causes the Date clas to fail to parse it and manipulate its values.
The values returned from getXXX() methods are based on the default values set on line 172
// unknown format
$this->year = 0;
$this->month = 1;
$this->day = 1;
$this->hour = 0;
$this->minute = 0;
$this->second = 0;
Reproduce code:
---------------
$d="2003-12-17T10:27:03Z";
$dateObj = new Date();
$dateObj->setDate($d, DATE_FORMAT_ISO_EXTENDED);
echo $dateObj->getMonth();
Expected result:
----------------
12
Actual result:
--------------
1
[2003-12-18 11:46 UTC] mike dot carter at personalmedicaladvisor dot co dot uk
Passing date string to the Date class constructor works fine. However I need to process many dates and don't (ideally) wish to keep creating a new instance of the date object per date.
Hope that quick test helps get the class fixed.
[2004-01-05 15:35 UTC] mike dot carter at personalmedicaladvisor dot co dot uk
Sorry for the delay - i have been away.
The setDate() is/was(?) the method causing the problem in the first place so the suggestion from pajoye@php.net would not help.
I am in the UK, so GMT.
I notice a new Date class has been released so will check this soon.