note 67802 deleted from function.date by bobby
| From: | bobby@php.net | Date: | Thu, 07 Sep 2006 17:52:58 +0000 |
| Subject: | note 67802 deleted from function.date by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-116851@lists.php.net to get a copy of this message | ||
Note Submitter: hsinche +at+ yahoo +dot+ com
----
<?php
// revolving Friday code
//
// This script displays this coming Friday's date, unless it
// is Friday after 9:45am, when it should show the next Friday's date.
// Alternatively, you can pass an hour and minute to the function.
function getFriday($hour = 9, $minute = 45) {
$day = 60 * 60 * 24; // 1 day is 60 seconds * 60 minutes * 24 hours
switch(date("l")) {
case "Friday":
$h = date("G");
switch(TRUE) {
case $h < $hour:
case ($h == $hour && date("i") < $minute):
$nextDate = date("F j, Y");
break;
default:
$t = time() + (7 * $day);
$nextDate = date("F j, Y", $t);
}
break;
default:
$mod = 5 - date("w");
if($mod < 0) {
$mod = 6;
}
$t = time() + ($mod * $day);
$nextDate = date("F j, Y", $t);
}
echo $nextDate;
}
?>