note 96062 added to function.date
| From: | markrose at markrose dot DELETEME dot ca | Date: | Fri, 05 Feb 2010 23:37:05 +0000 |
| Subject: | note 96062 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165703@lists.php.net to get a copy of this message | ||
If you only want to get the year, such as for a copyright notice in your footer, there is a much
faster way than using date("Y"):
<?php
$now = $_SERVER['REQUEST_TIME'];
$sec_per_yr = 31556926;
$year = ($now - ($now % $sec_per_yr)) / $sec_per_yr + 1970;
?>
$year will be accurate enough (within a day) for use in your footer. Modulo and integer division are
used because they're about twice as fast as using floor with floating point division in this
case.
----
Server IP: 66.207.199.35
Probable Submitter: 69.165.169.18
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/96062
Del: integrated -- https://master.php.net/note/delete/96062/integrated
Del: useless -- https://master.php.net/note/delete/96062/useless
Del: bad code -- https://master.php.net/note/delete/96062/bad+code
Del: spam -- https://master.php.net/note/delete/96062/spam
Del: non-english -- https://master.php.net/note/delete/96062/non-english
Del: in docs -- https://master.php.net/note/delete/96062/in+docs
Del: other reasons-- https://master.php.net/note/delete/96062
Reject -- https://master.php.net/note/reject/96062
Search -- https://master.php.net/manage/user-notes.php