Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0a4

Bug #445 Date does not handle DATE_FORMAT_ISO_EXTENDED correctly
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)    
Subscription  


 [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

Comments

 [2003-12-17 19:57 UTC] mroch
Please make sure to file bugs under their appropriate packages.
 [2003-12-17 20:08 UTC] mroch
There are 3 places the problem could lie: 1) In the constructor 2) The "Z" (in the setDate regexp) 3) The "T" (in the setDate regexp) Could you try it with: $dateObj = new Date("2003-12-17T10:27:03Z"); instead? If that still fails, try it without the Z. If it fails again, replace the T with a space. Then it's the same as the unit test and /should/ work. I don't have PHP installed on this machine at the moment, so I unfortunately can't test this myself. If you can pin down exactly where the problem is, I will be able to help.
 [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.
 [2003-12-20 14:07 UTC] pajoye
use setDate then. That skips the object creation for each date. The constructor use setDate, so the behiavor should be the same. What's the result of the suggestions done by Mike? pierre
 [2003-12-21 13:48 UTC] pajoye
In which timezone are you? (if not UK) pierre
 [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.
 [2006-12-01 11:30 UTC] firman (Firman Wandayandi)
This bugs no longer valid, already fixed in new version.