note 96062 deleted from function.date by danbrown
| From: | danbrown@php.net | Date: | Sat, 06 Feb 2010 16:53:04 +0000 |
| Subject: | note 96062 deleted from function.date by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165712@lists.php.net to get a copy of this message | ||
Note Submitter: markrose at markrose dot DELETEME dot ca
----
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.