php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65788 mktime return wrong month
Submitted: 2013-09-30 10:24 UTC Modified: 2013-09-30 10:38 UTC
From: condor at stz-bg dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.4.20 OS: Slackware 14.0 x64
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: condor at stz-bg dot com
New email:
PHP Version: OS:

 

 [2013-09-30 10:24 UTC] condor at stz-bg dot com
Description:
------------
Hello,

Im trying to get with date and mktime one year back from now and I think function return me wrong values.

Test script:
---------------
echo "Date Y-M\n";
echo date("Y-m");
$r = date("Y-m", mktime(0, 0, 0, 1, date("m") - 12, date("Y")));
echo "\n", $r,"\n";


Expected result:
----------------
2013-09
2012-09


Actual result:
--------------
2013-09
2012-12


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-30 10:38 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2013-09-30 10:38 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Please do this the right way:

$date = date_create("first day of this month 1 year ago");
echo $date->format('Y-m');
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu May 01 20:01:29 2025 UTC