User Defined Tag to display recurring date (e.g., meeting date)

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
User avatar
pixelita
Power Poster
Power Poster
Posts: 388
Joined: Sun Sep 16, 2007 3:07 am

User Defined Tag to display recurring date (e.g., meeting date)

Post by pixelita »

Our civic club wanted to post a recurring notice of our monthly meetings so I did some searching and found the PHP code that would do this.  It's now a User Defined Tag which displays each month's recurring meeting (in this case, the second Monday of every month). 

Here's the code for this tag:

Code: Select all

$t=getdate();
$today = mktime(0,0,0,$t['mon'],$t['mday'],$t['year']);

$this_month_start = mktime(0,0,0,$t['mon'],1,$t['year']);
$next_month_start = mktime(0,0,0,$t['mon']+1,1,$t['year']);

$this_month_date = strtotime("2 Monday",$this_month_start);
$next_month_date = strtotime("2 Monday",$next_month_start);

if($today <= $this_month_date) {
	$event_date = $this_month_date;
} else {
	$event_date = $next_month_date;
}
print "Monday, ".date('F j, Y',$event_date)." 7:00pm St. Austin Center";
Apparently PHP has some problems with declaring "second Monday" so I changed that to "2 Monday" and it works perfectly.  You can see it in action here:  http://www.idylwood.org
Last edited by pixelita on Mon Mar 03, 2008 3:49 am, edited 1 time in total.
Submit your site to the We Love CMSMS showcase
Post Reply

Return to “Tips and Tricks”