php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4096 mktime() & date() bug on Win32 Environment
Submitted: 2000-04-10 22:26 UTC Modified: 2000-10-02 19:05 UTC
From: chankor at netscape dot net Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0 Release Candidate 1 OS: Windows98
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
17 + 30 = ?
Subscribe to this entry?

 
 [2000-04-10 22:26 UTC] chankor at netscape dot net
Please check date function bug 

save this script as "birth.php" and 
enter "19650331" my birthday.
On Linux, It's Okey but,
php4ts.dll error would be happen on Win98 with Apach Webserver. PWS does it also.

<?
echo("
<form action=birth.php method=post>
<tr>
<td align=right>Birth(YYYYMMDD):  </td>
<td><input type=text name=\"birth\" size=8 maxlength=8></td>
</tr>
<tr>
<td align=center><input type=submit value=\"Check!\"></form></td>
</tr>");

// Birthday Checking
if (strlen($birth) == 8) {
    for ($i = 0; $i < 8; $i++) {
        $a[$i] = intval($birth[$i]);
    }
    // Birthday checking
    $Y = $a[0]*1000 + $a[1]*100 + $a[2]*10 + $a[3];
    $M = $a[4]*10 + $a[5];
    if (($M == 0) || ($M >12)) error("Invalid Month");
    $D = $a[6]*10 + $a[7];
    if (($D == 0) || ($D >31)) error("Invalid Day");
    $b_date = mktime(0, 0, 0, "$M", "$D", "$Y");
    $b_date = date("Y-m-d", $b_date);
    echo ( "Birth : $b_date");
} else {
    echo("Invalid Input");
}
?>

<?php
phpinfo();
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-17 07:50 UTC] hholzgra at cvs dot php dot net
negative timestamp (before 1970 that is) 
seem to crash windows time functions ...
 [2000-07-30 13:39 UTC] zak@php.net
I am grasping to understand the source code for this bug - mostly because it seems like it should be easy to tackle. :)

If I understand correctly, either the native win functions cannot handle dates beyond the start of epoch - or - the versions of gmtime_r, localtime_r and mktime used in the win C compilers are not very robust

php_mktime on win returns -1 for any date before the epoch.
php_date on win returns an error for any time value under 0

I am guessing that the only practical way to fix this is by writing the date/time calculation code directly into php - instead of relying on OS based libraries.
 [2000-08-06 18:43 UTC] stas@php.net
Well, one should use calendar functionf for such things, I guess. PHP can't do much if platform doesn't support it.
 [2000-08-06 23:44 UTC] hholzgra@php.net
there is a little difference between 'doesn't wort' and 'does crash'
 [2000-08-08 08:37 UTC] stas@php.net
Yes, it doesn't crash for me on Windows NT.
 [2000-08-08 08:58 UTC] waldschrott@php.net
marked 5987 as a dup
 [2000-09-02 19:32 UTC] sniper@php.net
Does it still happen when using php4.0.2 ??
And if it still crashing, please provide a backtrace.

--Jani
 [2000-10-02 19:05 UTC] sniper@php.net
No feedback.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 17:01:30 2024 UTC