ID: 6425
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Closed
Bug Type: Date/time related
Operating System: Windows NT 4.0 Workstation
PHP Version: 4.0.1pl2
New Comment:
This condition still exists in 4.1.2
I'm using Win2K Advanced Server with uptodate patchs (as of
1-April-2002). Tested with snipers test loop.
Trying: 1970-01-01 ...
Warning: unexpected error in date() in
c:\inetpub\wwwroot\entry_exam\testdate.php on line 5
Trying: 1971-01-01 ... January 1, 1971
Trying: 1972-01-01 ... January 1, 1972
.
.
.
Trying: 2038-01-01 ... January 1, 2038
Trying: 2039-01-01 ...
Warning: unexpected error in date() in
c:\inetpub\wwwroot\entry_exam\testdate.php on line 5
Previous Comments:
------------------------------------------------------------------------
[2000-12-07 11:35:12] [EMAIL PROTECTED]
No feedback.
------------------------------------------------------------------------
[2000-11-02 15:12:24] [EMAIL PROTECTED]
could you plese try the dev build from php4win.de and report wheter
this is fixed?
------------------------------------------------------------------------
[2000-09-06 17:16:51] [EMAIL PROTECTED]
reclassified..
------------------------------------------------------------------------
[2000-09-06 17:15:54] [EMAIL PROTECTED]
User feedback:
---------------------------
I was actually contacted on this issue once, and sent a corrected reply
as
follows. Keep in mind, this issue only occurs in _Windows_ versions of
PHP
including PHP 4.0.1pl2 and 4.0.2. UNIX varients do not seem effected.:
I've written a specific script to show this issue:
--- cut ---
<?php
for ( $i = 1900; $i < 2050; $i++) {
$datep = "$i-01-01";
print "Trying: $datep ... ";
print date("F j, Y", strtotime($datep));
print "<BR>"; // For clean display sake only
}
?>
--- cut ---
I also tested this with dates in 12-31, and 1969 failed, so 1970-01-01
is
the lowest possible date:
--- cut ---
Trying: 1900-01-01 ...
Warning: unexpected error in date() in d:\fhirsch\mysite\testdate.php
on
line 6
Trying: 1901-01-01 ...
Warning: unexpected error in date() in d:\fhirsch\mysite\testdate.php
on
line 6
Trying: 1902-01-01 ...
Warning: unexpected error in date() in d:\fhirsch\mysite\testdate.php
on
line 6
.
.
.
Trying: 1969-01-01 ...
Warning: unexpected error in date() in d:\fhirsch\mysite\testdate.php
on
line 6
Trying: 1970-01-01 ... January 1, 1970
Trying: 1971-01-01 ... January 1, 1971
Trying: 1972-01-01 ... January 1, 1972
Trying: 1973-01-01 ... January 1, 1973
Trying: 1974-01-01
.
.
.
Trying: 2038-01-01 ... January 1, 2038
Trying: 2039-01-01 ...
Warning: unexpected error in date() in d:\fhirsch\mysite\testdate.php
on
line 6
Trying: 2040-01-01 ...
Warning: unexpected error in date() in d:\fhirsch\mysite\testdate.php
on
line 6
... January 1, 1974
--- cut ---
It seems likely that the date() function uses internal calls within the
O/S
somehow on Windows, as this would correlate to what Windows/MSDOS is
(in)capable of doing. However, it hardly seems to be a desirable
side-effect
in a production quality programming language. Anyhow, let me know if
there
is other documentation you need from me.
---------------------------------------
Editorial note: PLEASE answer next time using the
web-interface.. =)
--Jani
------------------------------------------------------------------------
[2000-09-05 19:43:17] [EMAIL PROTECTED]
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
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/6425
--
Edit this bug report at http://bugs.php.net/?id=6425&edit=1