note 21610 added to function.getdate
| From: | stig at chs4 dot nospam dot com | Date: | Tue, 21 May 2002 08:21:31 +0000 |
| Subject: | note 21610 added to function.getdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30827@lists.php.net to get a copy of this message | ||
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;
}
--
http://www.php.net/manual/en/function.getdate.php
http://master.php.net/manage/user-notes.php?action=edit+21610
http://master.php.net/manage/user-notes.php?action=delete+21610
http://master.php.net/manage/user-notes.php?action=reject+21610