Auto updating copyright
A short function that helps you keeping the current year in your copyright sentence.
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; }
Author:
Jonas John
License:
Public Domain
Language:
PHP
Created:
04/24/2007
Updated:
04/24/2007
Tags:
date functions, examples, simple
print '© ' . autoUpdatingCopyright(2001) . ' Jonas John'; /* Output: (c) 2001-2007 Jonas John */
Sorry folks, comments have been deactivated for now due to the large amount of spam.
Please try to post your questions or problems on a related programming board, a suitable mailing list, a programming chat-room,
or use a QA website like stackoverflow because I'm usually too busy to answer any mails related
to my code snippets. Therefore please just mail me if you found a serious bug... Thank you!
Older comments:
So autoUpdatingCopyright(2006) would output
2006-2010
Your example just outputs 2010.
A matter of choice as to which you like best I guess... The range is common however...
© 2009 - <?xxx $year = (date('Y')); echo $year;?>
(xxx = php)