Dates in this week
By: Daniel
Finding the days in this week is very easy! If you are creating a calendar script or some kind of billing system you might need this. This code puts all the dates in this week into an array which you can use for whatever output you desire.
$lowEnd=date("w"); $lowEnd=-$lowEnd; $highEnd=$lowEnd + 6; $weekday=0; // Change this to make the Sunday index 1 for($i=$lowEnd; $i<=$highEnd; $i++) { $WeekDate[$weekday]=date("m/d",mktime(0, 0, 0, date("m") , date("d")+$i, date("Y"))); $weekday++; } echo '<pre>'; print_r($WeekDate); echo '</pre>';
This will output something like:
Array
(
[0] => 07/30
[1] => 07/31
[2] => 08/01
[3] => 08/02
[4] => 08/03
[5] => 08/04
[6] => 08/05
)



















(2 votes, average: 4.00 out of 5)