Quick PHP Tip
Did you remember to manually update your copyright statement to 2010? With one line of PHP all your problems can be solved!
By Jacob Haug on January 26th, 2010 in Tips & Tricks |
Recently, I was reading an article on Smashing Magazine called…”Don’t Forget The Small Stuff This Year“, and within that article it reminded users to update their copyright statement each new year!
Have you ever forgotten to update your copyright statement to 2010? I know I have, however; let’s make sure that doesn’t happen again. With this short PHP code snippet, your statement will automatically update! How cool is that?
<p><strong>© Copyright 2010 <a href="/">The Web Squeeze, LLC.</a> All Rights Reserved.</strong></p>
We’re going to change the above to…
<p><strong>© Copyright <?php echo date('Y'); ?> <a href="/">The Web Squeeze, LLC.</a> All Rights Reserved.</strong></p>
The key in the above code is this line…
<?php echo date('Y'); ?>
The above line of code is using PHP’s built in date function. We’re saying echo out the current year (Y) in a 4 digit format. (e.g. 2010) If you’ve never used the date function, or want to customize the above a bit further, check out the date function.
http://us2.php.net/manual/en/function.date.php
I hope this helps make your life just a tad easier!
Similar Posts
Want more web design and development tips?
Subscribe to The Web Squeeze by Email, or our RSS feed, and you'll have all the latest web design tips coming right to your inbox! Don't be a stranger, join our forum!









January 26th, 2010 at 10:00 am
I bet you are Jacob!
You have just reminded me to change them. I did read the same article in Smashing Magazine but somehow I did not think about it, silly me ^_^
January 26th, 2010 at 12:39 pm
Great tip! I always do this for designs since it would be a hassle to have to find each site I ever built each year, just to update that little number.
PHP saves the day, once again!
January 26th, 2010 at 5:30 pm
Nice little tip, Jacob
I believe technically copyright dates should be a range if they span more than one year (which they will if you’re changing the date).
So really, your code should be more like:
<p><strong>© Copyright 2008 – <?php echo date(‘Y’); ?> <a href=”/”>The Web Squeeze, LLC.</a> All Rights Reserved.</strong></p>
Or something similar
January 26th, 2010 at 7:34 pm
I saw people do like that. What is the different between that two?
Which is the best or should I say, which one should we use?
January 27th, 2010 at 4:02 pm
I wasn’t aware of this tip but this would certainly come in handy. I’m going to implement this on my client sites. I use a span of years in copyrights so Japh’s code will work well for the majority. However when I develop a brand new site for a new business, Jacob’s will work for the first year!
Thanks!
January 27th, 2010 at 4:07 pm
I wasn’t aware of this tip but this would certainly come in handy. I’m going to implement this on my client sites. I use a span of years in copyrights so Japh’s code will work well for the majority. However when I develop a brand new site for a new business, Jacob’s will work for the first year!
Thanks!
January 27th, 2010 at 6:23 pm
Hmm… so longer-lasting code then, so you can use it on new projects too!
<p><strong>© Copyright <?php $year=’2008′; echo (date(‘Y’) == $year ? $year : $year.’ – ‘.date(‘Y’)); ?> <a href=”/”>The Web Squeeze, LLC.</a> All Rights Reserved.</strong></p>
January 29th, 2010 at 6:25 am
I believe, from what I’ve read, that using a Copyright deceleration at the bottom of your website doesn’t matter. Anything you publish to the internet is copyright of the website, regardless of whether you have this deceleration or not. A Copyright deceleration, however, is useful if you are displaying another person’s work on your website.
Disclaimer:
Please remember, that in no way am I an IP (Intellectual Property) lawyer. Thus, accept no liability for the above statement.
February 1st, 2010 at 9:39 am
@Japh @Linda
It’s all a matter of personal preference which you use. It’s not required to use a range, however, some prefer that.
@Marc
That’s a good point Marc!