Who working for website, blog or web related applications, they will face this question at last. Why Last? Because, Footer is coming at last of the page 🙂 . Anyway, come on we will solve this problem. First simple solution,
<?php echo date("Y"); ?>
or
<?= date("Y") ?>
Use © <?php echo date("Y") ?> Copyright - All rights reserved.
for
© 2015 Copyright – All rights reserved.
Copyright Start and Current Years
If you want to display the Copyright year with Start and Current, just Use following code,
© 2013-<?php echo date("y") ?> Copyright - All rights reserved.
for
© 2013-15 Copyright – All rights reserved.
Auto Copyright generate function in PHP
<?php
function copyright_year($year = ‘ ‘)
{
$year = intval($year);
if($year == date(‘Y’)){ echo $year; }
else if($year < date(‘Y’)){ echo $year.’ – ‘.date(‘y’); }
else { echo date(‘Y’); }
}
?>
Output:
© <?php copyright_year();?>
// © 2015
© <?php copyright_year(‘2013’);?>// © 2013-15
Some time you may change by hard-code. That’s the sense. But Code make you God. So use following PHP code and make it simple.
Notes:
1) For last to number of YEAR use ‘y‘(lowercase)
2) For full YEAR use ‘Y‘(UPPERCASE)
3) Copyright Symbol©
html code – © or ©