note 53137 deleted from function.date by aidan
| From: | aidan@php.net | Date: | Sun, 31 Jul 2005 12:34:21 +0000 |
| Subject: | note 53137 deleted from function.date by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-92821@lists.php.net to get a copy of this message | ||
Note Submitter: yasingedikli at hotmail dot com
----
You can get the beginn and end date from weeknumber !
function dateweek($weeknumber)
{
$x = strtotime("last Monday");
$Year = date("Y",$x);
$Month = date("m",$x);
$Day = date("d",$x);
if ($Month < 2 && $Day < 8) {
$Year = $Year--;
$Month = $Month--;
}
if ($Month > 1 && $Day < 8)
$Month = $Month--;
//DATE BEGINN OF THE WEEK ( Monday )
$Day = $Day+7*$weeknumber;
echo date('Y-m-d', mktime(0, 0, 0, $Month, $Day, $Year));
//DATE END OF THE WEEK ( Sunday )
$Day = $Day+6;
echo date('Y-m-d', mktime(0, 0, 0, $Month, $Day, $Year));
}
// THIS WEEK
dateweek(0);
// LAST WEEK
dateweek(-1);
// NEXT WEEK
dateweek(1);
// 4 WEEK THEN
dateweek(4);