View Full Version : Simple Auto-Update Copyright Script

11-07-2005, 04:50 AM
This is a very simple php script I put together so I wouldn't have to update my copyright statements on all my sites (which I hope to eventually have lots of) each year. I know that it's very simple but, since it does no harm to share it, I figured maybe someone who doesn't know PHP or someone who does and didn't think of it could find it handy.

ITEM Copyright ©


if (date("Y") == '2005')
echo date("Y");
echo '2005-'; echo date("Y");


NAME. All Rights Reserved.

If the current year is 2005, it will display:

"ITEM Copyright 2005 NAME. All Rights Reserved."

If the current year is over 2005, it will display:

"ITEM Copyright 2005-XXXX NAME. All Rights Reserved."

Where XXXX is the current year.

Just replace "NAME" with your company or site's name and "ITEM" with whatever it is you're stating your copyright for (i.e "site", "layout" or "content") and you shouldn't have to touch it. Also, you can replace the captal Y in the third "date("Y")" with a lower-case "y" to display just the last 2 digits of the current year ("2005-06")... but I prefer the full year.

If you're seeing/using this in 2006+ just replace both 2005's in the PHP with your current year.

Again I know it's really simple but could save some time and effort over the years if you have a lot of sites.


here's a link to the date() function incase anyone has any other ideas for it:


11-07-2005, 12:05 PM
Your second '2005' really should be a variable so you don't have to change it in two places.

So ... $setup_year = '2005' ... if (date("Y") == $setup_year) .... echo $setup_year

And there is another way of doing it:

$setup_year = "2000";
$current_year = date("Y");

echo $setup_year;

if ($current_year != $setup_year) {
echo " - $current_year";

11-07-2005, 01:18 PM
here's the way I would do it. A lot shorter, and in the end when you have lots of pages that can be viewed, also quicker. :)

$setup_year = "2000";
$current_year = date("Y");
echo $setup_year.($current_year != $setup_year ? " - $current_year" : null);

11-07-2005, 01:53 PM
Yeah you guys are right. I'll have to update my pages.

I'm still pretty new to PHP so don't really know all the optimization, more focused on just getting the scripts to work heh. I should learn to optimize though incase a site I have gets big... it wont eat up all my resources and slow down my pages.

Thanks for fixing it.

11-09-2005, 04:13 PM
..there is more than one way to skin a cat.

11-09-2005, 05:38 PM
..there is more than one way to skin a cat.

A more efficient way to say that would have been, "There's more than one way to skin a cat." :D

11-10-2005, 02:48 AM
And a gramatically incorrect way would be
"There are more than one way to skin a cats."

11-24-2005, 05:38 PM
can any ASP CODE? :D

11-24-2005, 08:25 PM
CurrDate = Now()
CurrYearID = Month(CurrDate)
response.write "Copyright " & CurrYearID
Try that. I've just pieced it together based on what a quick Google search and scanning turned up, so it may not work.