|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-10-31 11:57 UTC] pmartinez at distridasa dot com
I have a problem with date() function;
In my PC, Today is 31-October-2001.
I would like to obtain precedent month and next month with this clause:
$month_before = date('m', mktime(0,0,0,date("m")-1,date("d"),date("Y")));
$month_next = date('m', mktime(0,0,0,date("m")+1,date("d"),date("Y")));
Surprisingly, I get this result:
$month_before is equal to 10
$month_next is equal to 12
This error just ocurrs this day "31-10-2001". Another day is ok.
I don't understand it !!!
Can anyone help me ??
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 11:00:02 2025 UTC |
Again same result and same reason. What does April 30th and June 30th have to do with your problem?? Last I checked the calendar works like this So you're telling me that 9/31 isn't the same calendar day as October 1st and Novemember 31st isn't the same calendar day as Dec 1st?? Sept Oct Nov Dec 30 1 2 3 ... 31 1 2 3 ... 30 1 2 3 <?php print "May\n"; print "Before: ".date("m", mktime(0,0,0,(5-1),31,2001))."\n"; print "After: ".date("m", mktime(0,0,0,(5+1),31,2001)). "\n"; print "October\n"; print "Before: ".date("m", mktime(0,0,0,(10-1),31,2001))."\n"; print "After: ".date("m", mktime(0,0,0,(10+1),31,2001)). "\n"; ?> [cnewbill@storm cnewbill]$ php -q t.php May Before: 05 After: 07 October Before: 10 After: 12 -Chris