note 80965 deleted from function.date by derick
| From: | derick@php.net | Date: | Wed, 07 May 2008 18:16:47 +0000 |
| Subject: | note 80965 deleted from function.date by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-139143@lists.php.net to get a copy of this message | ||
Note Submitter: lev dot ananikyan at gmail dot com
----
More elegant way to find week's end and begin for any date.
$day = isset($_GET['day'])? $_GET['day']: date("d",time());
$month = isset($_GET['month'])? $_GET['month']: date("m",time());
$year = isset($_GET['year'])? $_GET['year']: date("Y",time());
$w = date('w',mktime(0,0,0,$month,$day,$year));//Week day
$start_date = mktime(0, 0, 0, $month, $day-$w+1, $year); //Timestamp of Start
$end_date = mktime(0, 0, 0, $month, $day-$w+8 , $year); //Timestamp of End