note 21610 deleted from function.getdate by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 15 Sep 2004 16:38:28 +0000 |
| Subject: | note 21610 deleted from function.getdate by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76758@lists.php.net to get a copy of this message | ||
Note Submitter: stig at chs4 dot nospam dot com
----
If you need to find out the date of the begining of the week ie for timesheets etc. accounts for
month ends and month beginings.
$Tdate = getdate();
$theDate = date("d/m/Y");
$today = $Tdate['wday'];
$TDay = $Tdate['mday'];
$Month = $Tdate['mon'];
$Year = $Tdate['year'];
$MDay = $TDay-($today-1);
if ($MDay<=0)
{
$lastMonth = $Month-1;
$lastday = mktime(0,0,0,$Month,0,$Year);
$lastday = strftime("%d", $lastday);
$MDay = $lastday+$MDay;
$Month = $lastMonth;
}