note 100826 modified in function.date by danbrown

From: Date: Tue, 09 Nov 2010 17:03:07 +0000
Subject: note 100826 modified in function.date by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173887@lists.php.net to get a copy of this message
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; } ?> --was-- //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: echo last_business_day(2010,02); //2010-02-26 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; } http://php.net/manual/en/function.date.php

« previous php.notes (#173887) next »