note 97708 deleted from function.getdate by danbrown
| From: | danbrown@php.net | Date: | Tue, 04 May 2010 14:13:55 +0000 |
| Subject: | note 97708 deleted from function.getdate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-168923@lists.php.net to get a copy of this message | ||
Note Submitter: Denys M. from UK dg-1 at ya.ru
----
This function gives you the last working day of the month, unless that day is a Saturday or a Sunday
(weekend) day
for example if you need to get the day when salaries are paidon.
<?
function LastWorkDayOfMonth(){ //function returns
$result = strtotime("{$this->year}-{$this->month}-01"); //setting pointer
$result = strtotime('-1 second', strtotime('+1 month', $result)); //geting
last day
$theday=getdate($result);
if ($theday[weekday]=="Sunday"){ // if Sunday move pointer -2 days
$result = strtotime('-2 day', $result);
}
if ($theday[weekday]=="Saturday"){ // if Saturday move pointer -1 day
$result = strtotime('-1 day', $result);
}
return date('Y-m-d', $result); // return result
}
?>