Home » Date and Time » Date » Bug #2401
In Date::setDate(), $date should have seconds be optional
Details
| Request #2401 | In Date::setDate(), $date should have seconds be optional |
|---|---|
| Submitted | 2004-09-26 20:54 UTC |
| From | scragz at hotmail dot com |
| Assigned | pajoye |
| Status | Wont fix |
| Package | Date |
| PHP Version | 4.3.8 |
| OS | Debian Sarge |
| Roadmaps | (Not assigned) |
Comments
[2004-09-26 20:54 UTC] scragz at hotmail dot com
Description:
------------
Date::setDate() should be able to parse a datetime without seconds, e.g. "2004-09-26 13:30".
Reproduce code:
---------------
<?php
$date =& new Date('2004-09-26 13:30');
echo $date->year;
?>
This can be fixed by changing the setDate regexp to "/^(\d{4})-?(\d{2})-?(\d{2})([T\s]?(\d{2}):?(\d{2}):?(\d{2})?(\.\d+)?(Z|[\+\-]\d{2}:?\d{2})?)?$/i"
Expected result:
----------------
2004
Actual result:
--------------
0
[2004-11-05 12:59 UTC] pierre at dotgeek dot org
Hello,
Can you point to a doc which refers to this date time format?
ISO or others?
--Pierre
[2004-11-05 18:03 UTC] scragz at hotmail dot com
It's not a standard date. I was only trying to make the regex more versatile based on this comment found directly below it:
// DATE_FORMAT_ISO, ISO_BASIC, ISO_EXTENDED, and TIMESTAMP
// These formats are extremely close to each other. This regex
// is very loose and accepts almost any butchered format you could
// throw at it. e.g. 2003-10-07 19:45:15 and 2003-10071945:15
// are the same thing in the eyes of this regex, even though the
// latter is not a valid ISO 8601 date.
[2006-03-13 11:24 UTC] scragz at hotmail dot com
Is there a format argument where you can give it a custom (non-standard) format for the input that I'm missing?