note 100826 deleted from function.date by tularis
| From: | tularis@php.net | Date: | Thu, 09 Feb 2012 20:52:58 +0000 |
| Subject: | note 100826 deleted from function.date by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185968@lists.php.net to get a copy of this message | ||
Note Submitter: Gledison
----
Simple function to return the last business day of a given month (but this does not check holidays)
Função para retornar o último dia útil de um determinado mês (não verifica
feriados)
example:
<?php echo last_business_day(2010,02); //2010-02-26 ?>
<?php
function last_business_day($year,$month)
{
$lbd = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$wday = date("N",strtotime("$year-$month-$lbd"));
if ($wday == 7) $lbd -= 2;
if ($wday == 6) $lbd--;
$lbd = date("Y-m-d",strtotime("$year-$month-$lbd"));
return $lbd;
}
?>