Created
April 27, 2012 03:08
-
-
Save mebcomputers/2505353 to your computer and use it in GitHub Desktop.
php: auto update copyright
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function autoUpdatingCopyright($startYear){ | |
// given start year (e.g. 2004) | |
$startYear = intval($startYear); | |
// current year (e.g. 2007) | |
$year = intval(date('Y')); | |
// is the current year greater than the | |
// given start year? | |
if ($year > $startYear) | |
return $startYear .'-'. $year; | |
else | |
return $startYear; | |
} | |
print '© ' . autoUpdatingCopyright(2001) . ' Jonas John'; | |
/* | |
Output: | |
(c) 2001-2007 Jonas John | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment