Skip to content

Instantly share code, notes, and snippets.

@mebcomputers
Created April 27, 2012 03:08
Show Gist options
  • Save mebcomputers/2505353 to your computer and use it in GitHub Desktop.
Save mebcomputers/2505353 to your computer and use it in GitHub Desktop.
php: auto update copyright
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