note 37783 added to function.getdate

From: Date: Thu, 27 Nov 2003 01:35:48 +0000
Subject: note 37783 added to function.getdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-61011@lists.php.net to get a copy of this message
Here's how to figure the number of days in a month, leap years included. There's probably a better way to do this, but... function daysInMonth($month, $year) { $firstDay = mktime(0, 0, 0, $month, 1, $year); $dateData = getdate($firstDay); if ($month == 12) $daysInMonth = 31; else { $dayOfYearFirstOfThisMonth = $dateData['yday']; $firstOfNextMonth = mktime(0, 0, 0, $month + 1, 1, $year); $dateData = getdate($firstOfNextMonth); $dayOfYearFirstOfNextMonth = $dateData['yday']; $daysInMonth = $dayOfYearFirstOfNextMonth - $dayOfYearFirstOfThisMonth; } return $daysInMonth; } ---- Manual Page -- http://www.php.net/manual/en/function.getdate.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37783 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37783&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37783&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61011) next »