|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-06-01 15:52 UTC] jim at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Jul 06 08:00:01 2026 UTC |
mktime() appears to use the C mktime() function which takes years since 1900 hence the code line ta.tm_year = arguments[5]->value.lval - ((arguments[5]->value.lval > 1000) ? 1900 : 0); So the function should, I think, work correctly for dates in the ranges 70-137 and 1970-2037, and return -1 for other years. However, as the following code fragment shows, many other invalid dates are not detected and return incorrect values. for ($i = -100; $i < 32767; $i++) { $imod = $i - (($i > 1000) ? 1900 : 0); $timestamp = mktime(12, 0, 0, 1, 20, $i); if ($timestamp != -1) echo "$i, $imod => $timestamp => ".date("d M Y", $timestamp)."<br>\n"; } Would it not be best to put explicit date range tests into the function? In fact, shouldn't the function require 4 digit years and have a structure like if (year < 1970 || year > 2037) { return -1; } else { ... }