php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1529 gmmktime is broken
Submitted: 1999-06-11 15:29 UTC Modified: 1999-06-15 14:07 UTC
From: egon at tradeservices dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.9 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: egon at tradeservices dot com
New email:
PHP Version: OS:

 

 [1999-06-11 15:29 UTC] egon at tradeservices dot com
in functions/datetime.c, the code for translate to GMT is broken.  The (I think) fixed version would look like this:

void _php3_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm)
{
        pval *arguments[6];
        struct tm ta, *tn;
        time_t t;
        int i, gmadjust=0,arg_count = ARG_COUNT(ht);

        if (arg_count > 6 || getParametersArray(ht, arg_count, arguments) == FAI
LURE) {
                WRONG_PARAM_COUNT;
        }
        /* convert supplied arguments to longs */
        for (i = 0; i < arg_count; i++) {
                convert_to_long(arguments[i]);
        }
        t=time(NULL);
#if HAVE_TZSET
        tzset();
#endif
        tn = localtime(&t);
        memcpy(&ta,tn,sizeof(struct tm));
        ta.tm_isdst = -1;

        switch(arg_count) {
        case 6:
                ta.tm_year = arguments[5]->value.lval - ((arguments[5]->value.lv
al > 1000) ? 1900 : 0);
                /* fall-through */
        case 5:
                ta.tm_mday = arguments[4]->value.lval;
                /* fall-through */
        case 4:
                ta.tm_mon = arguments[3]->value.lval - 1;
                /* fall-through */
        case 3:
                ta.tm_sec = arguments[2]->value.lval;
                /* fall-through */
        case 2:
                ta.tm_min = arguments[1]->value.lval;
                /* fall-through */
        case 1:
                ta.tm_hour = arguments[0]->value.lval/* - gmadjust*/;
        case 0:
                break;
        }

        t=mktime(&ta); /* Need to do this because of Daylight savings */
        tn = localtime(&t);
        
        if (gm) {
#if HAVE_TM_GMTOFF
                gmadjust=(tn->tm_gmtoff)/3600;
#else 
                gmadjust=timezone/3600;
#endif
        }

        ta.tm_hour+=gmadjust;
 
        return_value->value.lval = mktime(&ta);
        return_value->type = IS_LONG;
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-15 14:07 UTC] egon at tradeservices dot com
I believe the problem has been fixed in the latest CVS.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 21:00:02 2026 UTC