RE: [PHP] Need to know the date of the Monday for the week I'm in.
| From: | Steve Keller | Date: | Mon, 07 Apr 2003 21:35:35 +0000 |
| Subject: | RE: [PHP] Need to know the date of the Monday for the week I'm in. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142756@lists.php.net to get a copy of this message | ||
At 4/7/2003 02:07 PM, Daevid Vincent wrote:
no. i mean that say the date was Wednesday April 9th (20030409), what i want is to know Monday April 7th (20030407). I should get the same result (20030407) if i pass in 20030413 as well, since that'd be the sunday of the same week (weeks go Mon - Sun in my calendar)<? // Get the number of the day of the week $thisDay = date("w"); if ($thisDay == 0) {
$thisday = 7; // Sunday} // Decrease by 1 to find the difference between Monday and the current day $dayDifference = $thisDay - 1; // Get a time code for Monday using this month and year, today minus the diff. $Monday = mktime(0,0,0,date("n"),(date("j")-$dayDifference),date("Y")); // Now use that time code to display the date: ?> This last Monday was: <h2> <? echo date("l",$Monday); ?>, <? echo date("F",$Monday); ?> <? echo date("j",$Monday); ?><? echo date("S",$Monday); ?>, <? echo date("Y",$Monday); ?> </h2> -- S. Keller UI Engineer The Health TV Channel, Inc. (a non - profit organization) 3820 Lake Otis Pkwy. Anchorage, AK 99508 907.770.6200 ext.220 907.336.6205 (fax) Email: skeller@healthtvchannel.org Web: www.healthtvchannel.org