I need a function which gives me the list of dates for certain weeks (date for every monday for 6weeks)
I am not aware of built in functions of PHP.... any easier way to do it...?
$dayOfWeek = 'Mon';
$numOfWeeks =6;
$meetingdays = array of date (10-23-06) all the mondays in 6 weeks
function weeklySchedule($dayOfWeek,$numOfWeeks,$meetingdays)
{
returns $meetingdays
}
I tried the following which works but except for wed
I believe there is an easier way.... Any suggestions
//The first letter needs to be capital
//$dayOfWeek = 'Fri';
//$numOfWeeks =6;
$addDays = 0;
function weeklySchedule($dayOfWeek,$numOfWeeks)
{
//if today is not the day of the week eg. Mon
$tomyes = mktime(0,0,0,date("m"),date("d"),date("Y"));
$today = date("D", $tomyes);
//Returns 0 when two strings are equal. if not equal
$matched = strcmp($today, $dayOfWeek);
if ($matched==1)
{
$nextStart = $today;
$i=1;
//untill we get to the day of the week find the day
While(strcmp($nextStart,$dayOfWeek))
{
$tomyes = mktime(0,0,0,date("m"),date("d")+$i,date("Y"));
$nextStart= date("D", $tomyes);
$i++;
}
//adds the difference of days eg. Tue - Fri
$addDays = $i-1;
}
//locates the files to be written for next $numOfWeeks
for ($i=0;$i<= $numOfWeeks; $i++)
{
//adds $sign for each day . Multiplies with i for next i days
$tomyes = mktime(0,0,0,date("m"),date("d")+$i*7+$addDays,date("Y"));
$tempdate = date("m-d-Y", $tomyes);
$filename ="$tempdate.txt ";
$file_list[$i]= "$tempdate.txt ";
echo $filename."<br>";
}
return $file_list;
}