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 Votes | Average: 5 out of 51 Votes | Average: 5 out of 51 Votes | Average: 5 out of 51 Votes | Average: 5 out of 51 Votes | Average: 5 out of 5 (1 votes, average: 5 out of 5)
Loading ... Loading ...
del.icio.us:Dates in this week digg:Dates in this week spurl:Dates in this week wists:Dates in this week simpy:Dates in this week newsvine:Dates in this week blinklist:Dates in this week furl:Dates in this week reddit:Dates in this week fark:Dates in this week blogmarks:Dates in this week Y!:Dates in this week smarking:Dates in this week magnolia:Dates in this week segnalo:Dates in this week

Leave a Reply

eXTReMe Tracker
geovisitors