DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
PHP Copyright Updater
// PHP Copyright Updater
// by Evan Walsh
// NothingConcept.com
This code will automatically change the copyright on your site as the year changes. Tested and approved by me.
Just call this in one of your PHP files by including the file with this code in it:
<?php
//Licensed under the GPL v2
//by Evan Walsh of nothingconcept.com
function copyright($site,$year) {
$current = date(Y);
if($year == $current) { $eyear = $year; }
else { $eyear = "$year - $current"; }
echo "All content © $eyear $site";
}
?>
Example: <?php include('functions.php'); ?>
Then place <?php copyright("Sitename","2007"); ?> or something similar in the place you want the copyright to display.
Simple as that.






Comments
Snippets Manager replied on Tue, 2007/03/13 - 10:24pm
<?php echo ($cr_start = 1996) != ($cr_end = date("Y")) ? "$cr_start - $cr_end" : $cr_end ?>Just change 1996 to the year you need.$cr_endisn't truly needed, but it halves the execution time (not that it should even be a factor).Snippets Manager replied on Tue, 2007/03/13 - 9:45pm