php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47892 mktime issue PHP4 vs 5.29
Submitted: 2009-04-03 17:32 UTC Modified: 2009-04-06 08:52 UTC
From: tommykvoom at gmail dot com Assigned:
Status: Not a bug Package: PHP options/info functions
PHP Version: 5.2.9 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tommykvoom at gmail dot com
New email:
PHP Version: OS:

 

 [2009-04-03 17:32 UTC] tommykvoom at gmail dot com
Description:
------------
Question ...
Why does this return an error with PHP5, but not with PHP4:

# PHP Warning [PHP]:: mktime() expects parameter 3 to be long, string given in file /home/web20con/public_html/netoffice/includes/library.php line 931

In this code: (as referenced in the error msg above)

function createDate($storedDate, $gmtUser)
{
    global $gmtTimezone;

    if ($gmtTimezone == 'true') {
        if ($storedDate != '') {
            $extractHour = substr($storedDate, 11, 2);
            $extractMinute = substr($storedDate, 14, 2);
            $extractYear = substr($storedDate, 0, 4);
            $extractMonth = substr($storedDate, 5, 2);
            $extractDay = substr($storedDate, 8, 2);

           return(date("Y-m-d H:i", mktime($extractHour + $gmtUser, $extractMinute, '', $extractMonth, $extractDay, $extractYear)));
          
        }
    } else {
        return($storedDate);
    }
}

Reproduce code:
---------------
---
From manual page: function.mktime
---
Question ...
Why does this return an error with PHP5, but not with PHP4:

# PHP Warning [PHP]:: mktime() expects parameter 3 to be long, string given in file /home/web20con/public_html/netoffice/includes/library.php line 931

In this code: (as referenced in the error msg above)

function createDate($storedDate, $gmtUser)
{
    global $gmtTimezone;

    if ($gmtTimezone == 'true') {
        if ($storedDate != '') {
            $extractHour = substr($storedDate, 11, 2);
            $extractMinute = substr($storedDate, 14, 2);
            $extractYear = substr($storedDate, 0, 4);
            $extractMonth = substr($storedDate, 5, 2);
            $extractDay = substr($storedDate, 8, 2);

           return(date("Y-m-d H:i", mktime($extractHour + $gmtUser, $extractMinute, '', $extractMonth, $extractDay, $extractYear)));
          
        }
    } else {
        return($storedDate);
    }
}

Expected result:
----------------
No errors.

This bug appears in the open source program 
NetOffice Version :	2.6.0b2 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-06 08:52 UTC] jani@php.net
Because PHP 5 is more strict about it. This is not a bug.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 02:01:32 2025 UTC