php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #37281 Year range in mktime
Submitted: 2006-05-02 18:39 UTC Modified: 2007-08-20 10:14 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: kprice at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2006-05-02 18:39 UTC] kprice at gmail dot com
Description:
------------
The documentation claims: "On systems where time_t is a 32bit signed integer, as most common today, the valid range for year is somewhere between 1901 and 2038, although this limitation is overcome as of PHP 5.1.0."

However, based on my testing this is not the case. mktime still returns FALSE for dates outside of this range.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-02 19:11 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.

Please also tell what your system is.
 [2006-05-03 11:25 UTC] derick@php.net
It's a documentation problem. Although *internally* the new code does support larger numbers it still can not return larger integers back to user land. So for calling PHP functions the result can never be outside this range.

However, the new date code which is going to make it into PHP 5.2 is going to provide functions to deal with this correctly.
 [2006-11-11 03:11 UTC] lucas at facebook dot com
Derick, is this true even on 64bit systems? We've run into this problem using mktime and strtotime on 5.2. For example:

mktime(0,0,0,1,1,1901) returns false
strtotime("1/1/1901") returns false

However 

date('r', -2178099690) returns:
Mon, 24 Dec 1900 04:18:30 -0800

I have not figured out how to return the timestamp from a DateTime object created with the string "1/1/1901".
 [2006-11-11 13:05 UTC] derick@php.net
php -r '$a = new DateTime("1/1/1901"); echo $a->format("U");'
-2177456400

However, you do have a point. I think we even break to 32bit ints on 64 bit systems. I can check that when somebody grants me access to a 64bit machine.
 [2007-03-07 18:52 UTC] jmorales at tucms dot com
Using this you get the error in DATE():

echo date("M d, Y", strtotime("12/4/2038");

This day is outside the 32 bit range and it overflows the 32bit stack.

I am using PHP 4.4 i forgot the rest, but version should be irrelevant... is anyone else getting this on v5.x.x ???
 [2007-03-07 18:55 UTC] morales2k at gmail dot com
There is an article on Wikipedia about this thing... check here:
http://en.wikipedia.org/wiki/Year_2038_problem
 [2007-08-20 10:14 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"However, before PHP 5.1.0 this range was limited from 1970 to 2038 on some systems (e.g. Windows)."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 09:01:33 2025 UTC