note 88776 added to function.date
| From: | twdsje at gmail dot com | Date: | Sat, 07 Feb 2009 00:34:47 +0000 |
| Subject: | note 88776 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-150329@lists.php.net to get a copy of this message | ||
Another slight adaptation from the code posted earlier that you might find slightly more useful.
http://us2.php.net/manual/en/function.date.php#87975
Takes a unix timestamp and returns the beginning or end of that week as a unix timestamp. If no
timestamp is provided the current time is used.
function weekStart($time = null)
{
if($time == null)
$time = time();
$sun = 0; //sunday = start of week
$dayOfWeek = date('w', $time);
$days_from_sun = $dayOfWeek - $sun;
return $time - $days_from_sun * 24 * 60 * 60;
}
function weekEnd($time = null)
{
if($time == null)
$time = time();
$sat = 6; //saturday = end of week
$dayOfWeek = date('w', $time);
$days_until_sat = $sat - $dayOfWeek;
return $time + $days_until_sat * 24 * 60 * 60;
}
----
Server IP: 64.71.164.2
Probable Submitter: 64.122.26.187
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/88776
Del: integrated -- https://master.php.net/note/delete/88776/integrated
Del: useless -- https://master.php.net/note/delete/88776/useless
Del: bad code -- https://master.php.net/note/delete/88776/bad+code
Del: spam -- https://master.php.net/note/delete/88776/spam
Del: non-english -- https://master.php.net/note/delete/88776/non-english
Del: in docs -- https://master.php.net/note/delete/88776/in+docs
Del: other reasons-- https://master.php.net/note/delete/88776
Reject -- https://master.php.net/note/reject/88776
Search -- https://master.php.net/manage/user-notes.php