Page 1 of 1

Auto copyright date update snippet

Posted: Mon Aug 28, 2006 9:30 pm
by hotnuts21
Here is a little bit of code that you can add to your new template.

Basically it takes the year you create your template, and if its still that year it shows it, if its not it shows the old year and then the new year.

So for exampl if you created your site this year you would want a copyright that looked something like
Copyright your site name 2006.

If your site has been online for a few years you would want a copyright that looked like this
Copyright your site name 2004 - 2006

This code will do this automatically and update each year saving you a bit of time and hassle :)

Code: Select all

	$copy = 'Copyright © Your Site Name '; // Change this to suit leave space at end
	$built = '2006'; // This is the year you built the site
	$date = date(Y);
	if ($date == $built) { echo $copy . $built; } else { echo $copy . $built .' - ' . $date; }
This bit of code is mainly for new sites and you havent been online long enough to have a copyright date spanning two years, if your going to add it to a site that is already older than a year use this alternative. (example uses site created in 2005)

Code: Select all

Copyright © Your Site Name 2005 - <?php echo date(Y); ?>
This will update the latest year automagically as your site goes on.

Hope this helps someone.

Re: Auto copyright date update snippet

Posted: Sun Jul 27, 2014 3:00 am
by Endriago
A few years and Joomla verision later on, this is still the simplest way to generate a self-updating date (year in this case) for a copyright info. At least the best one I've found so far.

Just wanted to add a way on how to include this PHP code in a module position instead of the template, it is using an extension named "Sourcerer" by NoNumber: ... ZXIiO30%3D

This extension will allow you to add the above mentioned PHP code (or any other code-language-etc. for that matter) to a module position.

I hope this helps!