ID:               48458
 Updated by:       [email protected]
 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] [email protected]

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

Reply via email to