logo

  • Blog
  • My Shopify Themes
  • Twitter
  • RSS

Dynamic PHP Copyright Date Code

on Thursday, 24 February 2011.

Pretty simple but pretty handy too! Here's a short tutorial to generate the current year in your footer's copyright declaration. It also detects if the the site has been running for less than a year to avoid the date printing out like this © 2011-2011 rather than just this © 2011.

Example: Your Company Name © 2010-2011 All Rights Reserved.

Both of these methods work the same way.

Pure PHP

echo "<p>Your Company Name &copy ";
$start_year = 2010; //change to the year you launched your website
echo (date('Y') == $start_year) ? $start_year : $start_year . "-" . date('Y');
echo " All Rights Reserved.</p>";

Mixed HTML & PHP

<p>Your Company Name &copy;
<?php
  $start_year = 2010; //change to the year you launched your website
  echo (date('Y') == $start_year) ? $start_year : $start_year . "-" . date('Y');
?>
All Rights Reserved.</p>

If you're looking to add the trademark symbol (™) or any others check out CopyPasteCharacter.com

  • Tags: How to, PHP, Tutorial
Tweet
blog comments powered by Disqus
Filter By
  • How to,
  • Tutorial,
  • PHP,
  • Joomla,
  • Animation,
  • SEO,
  • CSS,
  • Database,
  • Download,
  • eCommerce,
  • Apache,
  • Mac OS X Lion,
  • Permissions,
  • Effects,
  • Javascript