note 68919 added to function.time
| From: | tania at example dot com | Date: | Wed, 16 Aug 2006 03:25:20 +0000 |
| Subject: | note 68919 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115959@lists.php.net to get a copy of this message | ||
<?php
// calculate the dates for the start and end of the current week (i.e. Mon and Friday)
$days_before_friday = 5 - date("w"); // 5 represents friday, 'w' returns day of
the week (0-6)
if($days_before_friday == -1) // if today is saturday
{
$days_before_friday = 6; // get next Fri, rather than previous Fri
}
$friday = time() + ($days_before_friday * 24 * 60 * 60); // 24 hours; 60 mins; 60secs in a day
$monday = $friday - (4 * 24 * 60 * 60); // 4 days; 24 hours; 60 mins; 60secs in a day
/* testing code
echo "Today is " . date("l j F, Y") ."<br/>";
echo "Days before friday " . $days_before_friday ."<br/>";
echo "Next Fri is " . date("l j F, Y", $friday) . "<br/>";
echo "Last Mon is " . date("l j F, Y", $monday);
*/
?>
----
Server IP: 203.220.0.234
Probable Submitter: 130.194.13.106 (proxied: 130.194.180.46)
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.time.php
Edit -- https://master.php.net/note/edit/68919
Del: integrated -- https://master.php.net/note/delete/68919/integrated
Del: useless -- https://master.php.net/note/delete/68919/useless
Del: bad code -- https://master.php.net/note/delete/68919/bad+code
Del: spam -- https://master.php.net/note/delete/68919/spam
Del: non-english -- https://master.php.net/note/delete/68919/non-english
Del: in docs -- https://master.php.net/note/delete/68919/in+docs
Del: other reasons-- https://master.php.net/note/delete/68919
Reject -- https://master.php.net/note/reject/68919
Search -- https://master.php.net/manage/user-notes.php