note 31038 added to function.date
| From: | daevid at daevid dot com | Date: | Mon, 07 Apr 2003 23:57:44 +0000 |
| Subject: | note 31038 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46326@lists.php.net to get a copy of this message | ||
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.]
--
http://www.php.net/manual/en/function.date.php
http://master.php.net/manage/user-notes.php?action=edit+31038
http://master.php.net/manage/user-notes.php?action=delete+31038
http://master.php.net/manage/user-notes.php?action=reject+31038