Jump to content


Photo

Dates for Reoccurring Events


  • Please log in to reply
3 replies to this topic

#1 paulgobble

paulgobble
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 20 August 2006 - 06:02 PM

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

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 20 August 2006 - 07:49 PM

You will need a custom function for that. If you want one I can post one.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 20 August 2006 - 09:11 PM

try
<?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]


#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 20 August 2006 - 10:41 PM

I'll attach the function. If you prefer to write your own then don't look

[attachment deleted by admin]
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users