I found a PHP script on the net which would calculate an event that occurs on, for example, the 2nd Tuesday of each month.
I tried Googling to find a similar script that would output a weekly event, e.g., every Friday.
I tried modifying the original script by poking around php.net, but I know just enough to be dangerous.
Here is the script:
<?php
$t=getdate();
$today = mktime(0,0,0,$t['wday'],$t['year']);
$this_week_start = mktime(0,0,0,$t['wday'],1,$t['year']);
if ($t['wday'] == 0) {
$next_week_start = mktime(0,0,0,0,1,$t['year']+1);
} else {
$next_week_start = mktime(0,0,0,$t['wday']+1,1,$t['year']);
}
$this_week_date = strtotime("Sunday",$this_week_start);
$next_week_date = strtotime("Sunday",$next_week_start);
if($today <= $this_week_date) {
$event_date = $this_week_date;
} else {
$event_date = $next_week_date;
}
print "Sunday, ".date('F j, Y',$event_date)." at 11:00 a.m., Steak Kountry Buffet, 1010 Antoine Drive, Houston, Texas";
What it's doing now is outputting July 1, 2012 at 11:00 a.m. rather than the next recurring Sunday, which is March 19, 2012. I think my error lies within "mktime" but am not sure.
Any ideas? Thanks!