#48458 [Bgs]: mktime produces huge negative numbers

From: Date: Wed, 03 Jun 2009 11:11:39 +0000
Subject: #48458 [Bgs]: mktime produces huge negative numbers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-137999@lists.php.net to get a copy of this message
ID: 48458 Updated by: derick@php.net Reported By: post at oliver-schieche dot de Status: Bogus Bug Type: Date/time related Operating System: Debian 4 2.6.18-6-amd64 PHP Version: 5.2.9 New Comment: The year 109 is a long time in the past. As seconds are counted from 1970, getting a negative number happens for any year < 1970. Previous Comments: ------------------------------------------------------------------------ [2009-06-03 11:08:27] post at oliver-schieche dot de I know that years returned from localtime() start with 1900. But the problem with mktime still remains. for PHP 5.2.6 mktime(0,0,0,6,3,109) returns 1243980000 and the large negative number will be returned for the exact same call to mktime() in PHP 5.2.9 ------------------------------------------------------------------------ [2009-06-03 10:56:51] derick@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php $v['tm_year'] contains the years since 1900. ------------------------------------------------------------------------ [2009-06-03 10:52:32] post at oliver-schieche dot de Description: ------------ Trying to get mktime to create a timestamp for today at 00:00 hours, odd results are returned. Previous versions of PHP 5 returned a correct timestamp even without adding 1900 to the year. This change to mktime behavior was not documented in the ChangeLog. Reproduce code: --------------- $v = localtime(time(), TRUE); $tm1 = mktime(0, 0, 0, $v['tm_mon']+1, $v['tm_mday'], $v['tm_year']); $tm2 = mktime(0, 0, 0); Expected result: ---------------- tm1 == tm2 == 1243980000 // 2009-06-03 00:00:00 Actual result: -------------- tm1 = -58714246800 tm2 = 1243980000 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48458&edit=1

« previous php.bugs (#137999) next »