note 39528 added to function.mktime

From: Date: Sun, 01 Feb 2004 05:44:21 +0000
Subject: note 39528 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-64495@lists.php.net to get a copy of this message
Consider skipping months with mktime(). $nextmonth = date("M",mktime(0,0,0,date("n")+1,date("j"),date("Y"))); On any day in Januari you expect to get Feb, right? But on January 30th you'll get Mar. It will try Feb 30th, which doesn't exist, and skips another month. Therefore in this case present a day value that will certainly be legal in any month, like day "1". This will give you next month on any day of the year: $nextmonth = date("M",mktime(0,0,0,date("n")+1,1,date("Y"))); ---- Manual Page -- http://www.php.net/manual/en/function.mktime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39528 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39528&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39528&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64495) next »