note 38437 added to function.date
| From: | www dot theutherfish dot com at rn2 dot php dot net | Date: | Sun, 21 Dec 2003 09:19:16 +0000 |
| Subject: | note 38437 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62284@lists.php.net to get a copy of this message | ||
I recently made a small christmas countdown script. It currently only works in days e.g. start it at
the beginning of the month, but it can be adapted easily to include months by using the numerical
representations. Sorry about the use of crimbo in the vars, i was just making it as short as
possible, enjoy:
<?
$crimboday = 24;
$date = date('d');
$dayleft = $crimboday-$date;
$crimbohour = 18;
$hour = date('G');
$hourleft = $crimbohour-$hour;
$crimbomins = 60;
$mins = date('i');
$minsleft = $crimbomins-$mins;
if ($dayleft < 0) {
echo "Merry Christmas!";
}
else{
print $dayleft." days, ".$hourleft." hours and ".$minsleft." minutes until
Christmas!";
}
?>
Please note the $crimbohour variable should be 23 if you want it in the time zone of your server. As
my server is in seattle and i needed GMT, i minused 5 from this to give 18. The same can be done for
all time zones to make it display correctly for your time zone.
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38437
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38437&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38437&report=yes
Search -- http://master.php.net/manage/user-notes.php