> -----Original Message-----
> From: Erick [mailto:[EMAIL PROTECTED]]
> Sent: 12 March 2002 01:47
>
>
> I've been working on this for a little while now, without success. I
> want to compare the current date to a certain recurring date (ie:
> compare todays date to the date of the second Sunday of the a certain
> month). I have an event that happens on the second Sunday of
> each month,
> and I want to show the next date on which the event occurs,
> without just
> listing the next few months. Can anyone help?
Amazingly, I believe the following will do the trick:
$second_sun_next_month = strtotime('2sunday', strtotime('+month 1 '.date('F')));
Or, breaking it down into understandable chunks:
$this_month = date('F'); // 'March', as I write this!
$first_of_next_month = strtotime("+month 1 ${this_month}");
// interpreted by strtotime as "one month after the 1st of this month" -- i.e.
1st April
// returned value is a UNIX timestamp
$second_sun_next_month = strtotime('2sunday', $first_of_next_month);
// returns date of second Sunday counting from 1st of next month.
strtotime is actually quite a powerful beast, especially in its range of "relative"
dates -- go to http://uk.php.net/manual/en/function.strtotime.php and follow the "Date
Input Formats" link to get the full picture.
HTH
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php