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.

<?php
$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
)
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.00 out of 5)
Loading ... Loading ...

One Response to “Dates in this week”

  1. Mizuno Soccer Shoes Says:

    Comfortabl y, the post is really the freshest on this laudable topic. I match in with your conclusions and also definitely will thirstily look forward to your next updates. Simply saying thanks will not simply be sufficient, for the fantasti c clarity in your writing. I can perfect away grab your rss feed to stay abreast of any kind of updates. Nice work and much success in your business dealings!

geovisitors