Auto updating copyright
A short function that helps you keeping the current year in your copyright sentence.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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;
}
//Example:
print '© ' . autoUpdatingCopyright(2001) . ' Jonas John';
/*
Output:
(c) 2001-2007 Jonas John
*/
X
Url: http://www.jonasjohn.de/snippets/php/auto-updating-copyright.htm
Language: PHP | User: ShareMySnippets | Created: Oct 16, 2013