|  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: chankor at netscape dot net
New email:
PHP Version: OS:


 [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.

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

// 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");



Add a Patch

Pull Requests

Add a Pull Request


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]
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]
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]
there is a little difference between 'doesn't wort' and 'does crash'
 [2000-08-08 08:37 UTC]
Yes, it doesn't crash for me on Windows NT.
 [2000-08-08 08:58 UTC]
marked 5987 as a dup
 [2000-09-02 19:32 UTC]
Does it still happen when using php4.0.2 ??
And if it still crashing, please provide a backtrace.

 [2000-10-02 19:05 UTC]
No feedback.
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC