note 68269 deleted from function.date by tularis

From: Date: Thu, 09 Feb 2012 21:05:11 +0000
Subject: note 68269 deleted from function.date by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-186032@lists.php.net to get a copy of this message
Note Submitter: Alvin Delagon ---- Here's a function that takes the year as input and returns an array or dates that are mondays. (It can be used for generating weekly reports just like I did) <?php function getMondays($year) { $newyear = $year; $week = 0; $day = 0; $mo = 1; $mondays = array(); $i = 1; while ($week != 1) { $day++; $week = date("w", mktime(0, 0, 0, $mo,$day, $year)); } array_push($mondays,date("r", mktime(0, 0, 0, $mo,$day, $year))); while ($newyear == $year) { $test = strtotime(date("r", mktime(0, 0, 0, $mo,$day, $year)) . "+" . $i . " week"); $i++; if ($year == date("Y",$test)) { array_push($mondays,date("r", $test)); } $newyear = date("Y",$test); } return $mondays; } ?>

« previous php.notes (#186032) next »