note 31038 deleted from function.date by sniper
| From: | sniper@php.net | Date: | Sat, 11 Oct 2003 16:53:43 +0000 |
| Subject: | note 31038 deleted from function.date by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58289@lists.php.net to get a copy of this message | ||
Note Submitter: daevid@daevid.com
----
Here's a helpful function to find what is the Monday date in YYYMMDD of any given date in the
same format. Useful for showing something like, "what's happening this week" when
pulling data from a database and showing a summary for the week your in; perhaps in a calendar or
such...
function findMonday($date)
{
//$date is in the mySQL form of YYYYMMDD
$year = intval(substr($date,0,4));
$month = intval(substr($date,4,2));
$day = intval(substr($date,6,2));
$dow = ((date("w", mktime(0,0,0,$month,$day,$year)) + 6) % 7);
$monDate = date("Ymd", mktime(0,0,0,$month,($day-$dow),$year));
return $monDate;
}
[thanks to "jpoz at quickscribble dot com" for the initial code.]