php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53798 specify range for month and day in mktime
Submitted: 2011-01-20 11:41 UTC Modified: 2011-01-26 12:06 UTC
From: matteosistisette at gmail dot com Assigned: rquadling (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: matteosistisette at gmail dot com
New email:
PHP Version: OS:

 

 [2011-01-20 11:41 UTC] matteosistisette at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.mktime
---

Documentation says about the "month" parameter:
"month

    The number of the month.
"

It should specify that this is 1-based, i.e. January is 1 and December is 12.

This is not obvious, as some languages use 0-based indexes (i.e. 0 for january and 11 for december)

To be rigorous, the same holds for days, thought I guess it is more obvious that the first day of the month is counted as 1 and not 0 so this may not be necessary, thought it wouldn't hurt.

Anyway for the number of the month it is absolutely vital to specify it.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-20 11:46 UTC] rquadling@php.net
-Status: Open +Status: Bogus
 [2011-01-20 11:46 UTC] rquadling@php.net
The day, month and year values supplied are not indexes or offsets, so "0-based" 
is not relevant.
 [2011-01-20 12:09 UTC] matteosistisette at gmail dot com
Well that's exactly what should be specified in the documentation, or more simply:

Month: number of the month (1 through 12)

just like it is documented for the date() function
 [2011-01-20 13:49 UTC] rquadling@php.net
-Status: Bogus +Status: Re-Opened -Assigned To: +Assigned To: rquadling
 [2011-01-20 13:49 UTC] rquadling@php.net
Actually it is a little more complicated than that. You can have any value, including negatives and values greater than the expected range.

For today, 20th Jan 2011,

php -r "echo date('r', mktime(0,0,0,-10,-3));"

Thu, 28 Jan 2010 00:00:00 +0000
 [2011-01-26 12:06 UTC] rquadling@php.net
Automatic comment from SVN on behalf of rquadling
Revision: http://svn.php.net/viewvc/?view=revision&revision=307764
Log: mktime and gmmktime's params are a little more complex. Fix bug#53798
 [2011-01-26 12:06 UTC] rquadling@php.net
-Status: Re-Opened +Status: Closed
 [2011-01-26 12:06 UTC] rquadling@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.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 17:00:02 2026 UTC