Method One
<?php Tutorial
Echo Strtotime (' last Monday ');
echo ' <br/> ';
Echo Strtotime (' next Sunday ');
?>
Method Two
?
The function Getmonsun () {
$curTime =time ();
04
$curWeekday = Date (' W ');
06
07/0 is the week Seven
$curWeekday = $curWeekday $curWeekday: 7;
09
10
One $curMon = $curTime-($curWeekday-1) *86400;
$curSun = $curTime + (7-$curWeekday) *86400;
13
$cur [' Mon '] = $curMon;
$cur [' Sun '] = $curSun;
16
return $cur;
18}
$cur = Getmonsun ();
20
echo Date (' y-m-d ', $cur [' Mon ']);
echo "RN";
echo Date (' y-m-d ', $cur [' Sun ']);
?>
Method Three
?
The function Getmonsun () {
$curTime =time ();
04
05//Find out the current day of the week:
$curWeekday = Date (' W ');
07
08///If Monday is reduced to 7*86400 Tuesday minus 6*86400, and so on to get the Monday timestamp:
Switch ($curWeekday) {
Case 0:
One $curMon = $curTime -7*86400;
$curSun = $curTime;
break;
Case 1:
$curMon = $curTime;
$curSun = $curTime +6*86400;
break;
Case 2:
$curMon = $curTime -1*86400;
$curSun = $curTime +5*86400;
break;
Case 3:
$curMon = $curTime -2*86400;
$curSun = $curTime +4*86400;
break;
Case 4:
$curMon = $curTime -3*86400;
$curSun = $curTime +3*86400;
break;
Case 5:
$curMon = $curTime -4*86400;
$curSun = $curTime +2*86400;
The break;
Case 6:
$curMon = $curTime -5*86400;
$curSun = $curTime +1*86400;
The break of the Panax Notoginseng;
38}
$cur [' Mon '] = $curMon;
$cur [' Sun '] = $curSun;
41
return $cur;
43}
$cur = Getmonsun ();
The Echo date (' y-m-d ', $cur [' Mon ']);
The echo "RN";
The Echo date (' y-m-d ', $cur [' Sun ']);
?>