Jump to content

Archived

This topic is now archived and is closed to further replies.

paulgobble

Dates for Reoccurring Events

Recommended Posts

Before I do a bunch of (probably unnecessary and redundant) coding, I thought I ask if anyone knows a simple way to do this.

Given any date, I need to know the next "third Tuesday" that comes after it.  I deal with a lot of groups that hold their meetings of the "second Monday" or "third Tuesday" of the month so I'd like to code reminders for them.  After looking through the php.net docs, I found a lot of date functions but not something like this.  Did I overlook something?

Thanks,
Paul

Share this post


Link to post
Share on other sites
You will need a custom function for that. If you want one I can post one.

Share this post


Link to post
Share on other sites
try[code]
<?php
$after = 3; // number of weeks
$look_day = 4; // 0 is Sun, 1 is Mon etc

$t=time();
$d = date('w');

$after = ($d >= $look_day) ? $look_day - $d + $after * 7 : $look_day - $d + --$after * 7;
$t_new = $t + 86400 * $after;
echo date('D d. M Y',$t_new);

?>
[code][/code][/code]

Share this post


Link to post
Share on other sites
I'll attach the function. If you prefer to write your own then don't look

[attachment deleted by admin]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.