Re: Last Friday of every month
| From: | Eric Butera | Date: | Fri, 14 Mar 2008 12:17:35 +0000 |
| Subject: | Re: Last Friday of every month | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271566@lists.php.net to get a copy of this message | ||
On Thu, Mar 13, 2008 at 9:39 PM, Andrés Robinet <agrobinet@bestplace.biz> wrote:
> > -----Original Message-----
> > From: VamVan [mailto:vamseevan@gmail.com]
> > Sent: Thursday, March 13, 2008 9:13 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] Last Friday of every month
> >
> > Can you tell me how to do this ?
> >
> > suppose I have a date variable = '02/23/2008'
> >
> > i need to know if this is the last friday of february....
> >
> > let me know.
>
> My view...
>
> $strDate = '02/23/2008';
> //
> $intDate = strtotime($strDate);
> $numDaysInMonth = date('t', $intDate);
> $dayOfWeek = date('w', $intDate);
> $dayOfMonth = date('j', $intDate);
> If ($dayOfWeek == 5 && $numDaysInMonth - $dayOfMonth < 7) {
> echo "Friday Party!";
> } else {
> echo "Sorry dude, you missed it";
> }
>
> Btw, read the manual (and don't think to be so lucky to not found any bugs in my
> code).
>
> Regards,
>
> Rob(inet)
>
>
> Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
> 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 |
> TEL 954-607-4296 | FAX 954-337-2695 |
> Email: info@bestplace.net | MSN Chat: best@bestplace.net | SKYPE: bestplace |
> Web: bestplace.biz | Web: seo-diy.com
>
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Just FYI you can use the word "last friday" in strtotime. So really
you could check and see if the max day in a month is a friday and if
not fall back on last friday. I didn't test it but I just thought I'd
throw that out there.
erics:~ eric$ php -r "echo date('n/j/Y', strtotime('last friday'));"
3/7/2008