Afficher un message
Vieux 14/03/2008, 10h01   #3
Aschwin Wesselius
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Last Friday of every month

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....'/

  Réponse avec citation
 
Page generated in 0,04466 seconds with 9 queries