how to get first and last day of the week in a given month using php . I tried to get the answer by googling but un-abale to get it . Please help me any body . I will be gr8 for him.
Asked
Active
Viewed 145 times
1 Answers
0
Hi every body some how i got solution and it is given below.
$fstSunday = date("d-F-Y", strtotime("first Sunday of ".date('M')." ".date('Y')."")); $weekArray = getfstlastdayOfWeekofmonth($fstSunday); echo '
';
print_r( $weekArray);
function getfstlastdayOfWeekofmonth($paramFstSundayofMonth)
{
$fstSunday = $paramFstSundayofMonth;
//echo 'last date of the week-'.$oneWeekLater = date('d-m-Y', strtotime('+1 week',strtotime($fstSunday)));
$countMnth = date("t",strtotime($fstSunday));
$dayOfmonth = date("d",strtotime($fstSunday));
if($countMnth==31 && $dayOfmonth <= 3)
$countmonth = 5;
else
$countmonth = 4;
$weekArray = array();
for($i=0;$i<$countmonth;$i++)
{
$oneWeekLater = date('d-F-Y', strtotime('+1 week',strtotime($fstSunday)-1));
$weekArray[] = array('fstdayWeekOfmonth'=> $fstSunday,'lastDayWeekOfmonth'=>$oneWeekLater) ;
$fstSunday = date('d-F-Y', strtotime('+1 week',strtotime($fstSunday)));
}
// echo '<pre>';
return $weekArray;
}

pradyumn
- 1