note 32093 added to function.date

From: Date: Fri, 16 May 2003 04:55:02 +0000
Subject: note 32093 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-48096@lists.php.net to get a copy of this message
To get the number of days in the current month: $daysInMonth = date( "j", mktime(0, 0, 0, date("n",time()) + 1, 1, date("Y",time())) - 1 ); This can also be used as a function: function getDaysInMonth($month=null,$year=null) { if ($month==null) { $month = date("n",time()); } if ($year=null) { $year = date("Y",time()); } $dim = date( "j", mktime(0, 0, 0, $month + 1, 1, $year) - 1 ); return $dim; } This will let you call the function to get the current months last day, or you can pass in a month and year to get the corresponding last day. -- http://www.php.net/manual/en/function.date.php http://master.php.net/manage/user-notes.php?action=edit+32093 http://master.php.net/manage/user-notes.php?action=delete+32093 http://master.php.net/manage/user-notes.php?action=reject+32093

« previous php.notes (#48096) next »