Re: Last Friday of every month
| From: | Aschwin Wesselius | Date: | Fri, 14 Mar 2008 08:01:31 +0000 |
| Subject: | Re: Last Friday of every month | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271561@lists.php.net to get a copy of this message | ||
VamVan wrote:
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.$month = 3; $year = 2008; for ($day = 31; $day >= 21; $day--) { // maximum of 7 days, but february starts at 28
$tmp_time = mktime(0, 0, 0, $month, $day, $year);
if (date('w', $tmp_time) === '5') { // 5 = friday
return date('d-m-Y', $tmp_time);
// return $day.'-'.$month.'-'.$year; // without the function it is faster off course
// echo 'Yeah, friday!';
}
}
Something similar worked for me to find out when daylight saving time is.
--
Aschwin Wesselius
/'What you would like to be done to you, do that to the other....'/