Jump to content

Dates for Reoccurring Events


paulgobble

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
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.