Re: Calendar Problem
| From: | Shawn McKenzie | Date: | Tue, 11 Aug 2009 20:53:42 +0000 |
| Subject: | Re: Calendar Problem | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-296676@lists.php.net to get a copy of this message | ||
Shawn McKenzie wrote:
> tedd wrote:
>> Hi gang:
>>
>> I want to show the dates for all Fridays +-30 days from a specific date.
>>
>> For example, given today's date (8/11/2009) the Fridays that fall +-30
>> days are July 17, July 24, July 31, Aug 7, Aug 14, Aug 21, Aug 28, and
>> Sept 4.
>>
>> I'm curious, how would you guys solve this?
>>
>> Cheers,
>>
>> tedd
>
> Lots of ways to skin that cat, here is one:
>
> $date = time(); //or whenever
> $start = strtotime('-30 days', $date);
> $end = strtotime('+30 days', $date);
>
> $next = $start;
> while(($next = strtotime('Next Friday', $next)) <= $end) {
> echo date("F j, Y", $next)."\n";
> }
>
I must be bored:
for($next = strtotime('-30 days');
$next <= strtotime('+30 days');
$next = strtotime('Next Friday', $next))
{
echo date("F j, Y", $next)."\n";
}
--
Thanks!
-Shawn
http://www.spidean.com