note 51971 deleted from function.date by victor

From: Date: Sun, 17 Apr 2005 14:03:56 +0000
Subject: note 51971 deleted from function.date by victor
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-88119@lists.php.net to get a copy of this message
Note Submitter: christian at maxnamara dot com Reason: useless ---- Here is my code to find date end of last month. <? function days_in_month($month, $year) { // calculate number of days in a month return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31); } function end_of_last_month() { $month = gmstrftime("%m", time () + 25200); $year = gmstrftime("%Y", time () + 25200); if(substr($month,0,1) == "0"){ $month = substr($month,1,1); } $month = intval($month); $year = intval($year); if($month == 1){ $last_month = 12; $year--; } else{ $last_month = $month - 1; } $date = days_in_month($last_month, $year); $eolm = "".$year."-".$last_month."-".$date.""; $ddate = date("d M Y",strtotime($eolm)); return($ddate); } $a = end_of_last_month(); echo $a; ?>

« previous php.notes (#88119) next »