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
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.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 11:01:37 2024 UTC