php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #44005 mktime invalid return value
Submitted: 2008-01-31 19:31 UTC Modified: 2008-11-07 13:14 UTC
From: felixl at densi dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: win XP SP2
Private report: No CVE-ID: None
 [2008-01-31 19:31 UTC] felixl at densi dot com
Description:
------------
The doc of mktime says this:

'Before PHP 5.1.0, negative timestamps were not supported under any known version of Windows and some other systems as well. Therefore the range of valid years was limited to 1970 through 2038.'

This text also means this:

php version higher then 5.1.0 can have a greater range then 1970 through 2038.

Also, in the doc:

'The number of the year, may be a two or four digit value, with values between 0-69 mapping to 2000-2069 and 70-100 to 1970-2000. 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. However, before PHP 5.1.0 this range was limited from 1970 to 2038 on some systems (e.g. Windows).'

Which clearly specify that date as high as 2069 are possible.

Strange because a date in 2050 doesn't work.

2 possibles solution:

 - correct the bug
 - change the doc

Reproduce code:
---------------
$year = 2050;
    $month = 10;
    $day = 17;
    $hour = 10;
    $min = 32;
    $sec = 0;

    $valid = mktime($hour, $min, $sec, $month, $day, $year);

    print $valid;


Expected result:
----------------
a valid timestamp

Actual result:
--------------
false

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-31 20:11 UTC] derick@php.net
mktime/strtotime still return an signed integer. If you're on 32bits, this makes the range limited to 1901-2038. There are how ever other functions that always support larger ranges. It's all the functions that deal with the DateTime class.

I don't agree with your statement though that the docs specify that it supports up to 2069 on 32 bit machines... because "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."
 [2008-11-07 13:14 UTC] vrana@php.net
69 maps to 2069 which is out of range. There's no conflict.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Fri Jun 12 00:00:02 2026 UTC