PHP 4.0 Bug #6425 Updated: date() parsing functionality provides unexpected results.
| From: | Bug Database | Date: | Tue, 05 Sep 2000 23:43:18 +0000 |
| Subject: | PHP 4.0 Bug #6425 Updated: date() parsing functionality provides unexpected results. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-32270@lists.php.net to get a copy of this message | ||
ID: 6425
Updated by: sniper
Reported By: hirschf@home.com
Status: Feedback
Bug Type: Feature/Change Request
Assigned To:
Comments:
Your example code was buggy, below corrected one:
<?php
function parseDate($date,$format) {
$dateString = date($format , strtotime($date));
return $dateString;
}
$db_birth_date = "1969-09-13 00:00:00";
$birth_date = parseDate($db_birth_date,"F j, Y");
echo $birth_date;
?>
And this works just like it should (in Linux)..
Please try this and report back.
--Jani
Previous Comments:
[2000-08-29 19:58:01] hirschf@home.com
On Windows NT, using Apache tested in PHP 4.0.1PL2, 4.0.2 for Win NT using
Apache CGI PHP. The function date() with MySQL date format of
YYYY-MM-DD HH:MI:SS
yields an error when using dates with a value lower than 1970-01-01 00:00:00.
The following error is actually reported:
Warning: unexpected error in date() in Program.php line XXX
Below is a script which reproduces this error:
$db_birth_date = "1969-09-13 00:00:00";
$birth_date = $parseDate($db_birth_date',"F j, Y");
function parseDate($date,$format) {
$dateString = date($format , strtotime($date));
return $dateString;
}
Have not tested this issue on UNIX system yet.
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=6425