PHP – Current Year for Copyright

PHP - Current Year for Copyright Footer
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 &copy; <?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,
&copy; 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:

&copy; <?php copyright_year();?> // © 2015
&copy; <?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 – &copy; or &#169;

PHP – Current Year for Copyright

Just share...Share on FacebookShare on Google+Tweet about this on TwitterPin on PinterestEmail this to someone
The following two tabs change content below.
I am Karthik, software engineer by profession. You can find and follow me, from Social Media or here. Google+

Latest posts by karsho (see all)

This entry was posted in Code, PHP.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please Fill this Sum * Time limit is exhausted. Please reload the CAPTCHA.