|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #47084 Calling mktime() w/o arguments raises strict error
Submitted: 2009-01-13 10:25 UTC Modified: 2009-08-01 12:05 UTC
Avg. Score:3.0 ± 1.2
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:2 (50.0%)
From: Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2009-01-13 10:25 UTC]
This code below will generate a strict error.

Also the documentation 
a) states that mktime() can be called w/o arguments
   int mktime  ([ int $Stunde  [, int $Minute  [, int $Sekunde  [, int $Monat  [, int $Tag  [, int $Jahr  [, int $is_dst  ]]]]]]] )
b) does not recommend using time() instead of mktime()

Reproduce code:



Actual result:
Strict standards: mktime(): You should be using the time() function instead


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-01 06:14 UTC] apradhan at sampatti dot com
I have seen a issue in mktime() for the date of  31 july

like if we write 
echo date("m",mktime(0,0,0,07-1,31, 2009));

Above code will give output : 07
while logically it should be 6.
 [2009-08-01 12:01 UTC]
Automatic comment from SVN on behalf of salathe
Log: Fixes #47084 Document mktime() E_STRICT with no arguments
 [2009-08-01 12:05 UTC]
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.

I have added a note and changelog to the mktime page to inform of the E_STRICT when called with no arguments, making reference to use time() instead.

apradhan at sampatti dot com: that is intended behaviour. There are only 30 days in June, so by using 31 as the $day argument it rolls over to the first of July.
 [2011-05-26 02:39 UTC] pansit at yahoo dot com dot ph
I would like to ask (as this has been brought up from pear but no answer was made), why is time() recommended to use than gmmktime()?

I'm using PHP 5.3.6 with strict on and I got this message:

Strict Standards: gmmktime() [function.gmmktime.html]: You should be using the time() function instead
 [2011-11-16 10:49 UTC] niklas dot karlssonn at gmail dot com
The error message its not correct either, use the time() instead of mktime? The functions does not return the same result, time() doesn't respect the timezone setting.
 [2013-08-08 17:06 UTC] karlorbell at hotmail dot com
As the previous commenter has said, this is an invalid E_STRICT message.

People use mktime() without arguments as a locale-aware version of time() - it's 
not an uncommon usage.  As the two functions do not give the same output, it is 
ludicrous to issue a warning to use the other.
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC