php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #34765 Parameter checking, especially in date/time functions
Submitted: 2005-10-06 18:35 UTC Modified: 2005-10-10 11:45 UTC
From: csg at diatom dot de Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.4.0 OS: Linux, probably all
Private report: No CVE-ID: None
 [2005-10-06 18:35 UTC] csg at diatom dot de
Description:
------------
Giving some functions  -like mktime()- invalid parameters, the result will be unpredictable - at least from users point of view (see Bug-ID 34760, marked as "Bogus" - sorry for my mistakes there).

Suggestion:
I suggest to emit at least a warning, if functions internal to PHP get wrong parameters (like an invalid [octal] number)
- instead of silently ignoring the problem and return unexpected results (as it is currently the case).

Rem.: Of course, numbers with leading zero as in the code example below will be treated as octal numbers and digit "8" is not allowed there - but usually date and time values *will* be given in a 2 or 4 digit format, so using mktime() this way is at least error prone.
So, a warning emited in such a case would be ***very*** fine resp. would help, to find such errors easier.


Reproduce code:
---------------
<?php mktime(15,0,0,10,08,2005); ?>

Expected result:
----------------
A Timestamp for "Oct-08-2005 15:00", e.g. the number "1 128 776 400" (without the spaces, of course).


Actual result:
--------------
A Timestamp for "Sep-30-2005 15:00", e.g. number "1 128 085 200".



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-10 11:45 UTC] tony2001@php.net
There is nothing wrong with those parameters.
Negative or zero params are perfectly valid for mktime(). 
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jun 03 10:00:02 2026 UTC