
HOW TO: Automatically Update The Copyright Year
- Updated On 23/04/2011
- Author : Pradeep Kumar
- Topic : Blogging • Guides
- Short URL : https://hellboundbloggers.com/?p=1732
CONNECT WITH HBB ON SOCIAL MEDIA
Manually updating the copyright year could be annoying to everyone. We need to change the copyright year every year. But there is a solution for this indeed. You can automatically update the copyright year using PHP and also using JavaScript.
These code snippets updates the copyright year automatically. JavaScript code works on any webpages whereas PHP code works only on PHP pages. But both they have their own advantages.
JavaScript Code Snippet
<script type="text/javascript">
now=new Date();
year=now.getFullYear();
</script>© Copyright 2008-<script type="text/javascript">
document.write(year);
</script>
The output will be like this :
© Copyright 2008-2009
Note : You should update the starting year for your copyright year.
PHP Code Snippet
© Copyright <?php
$then = 2007;
$now = date(’Y');
if ($then == $now)
echo $now;
else
echo "$then - $now"; ?>
You can also try this snipper for simplity of code
© Copyright 2007 - <?php echo date('Y'); ?>
Note : You need to edit $then for setting it to the year your blog launched. The final year is automatically calculated using date() function of PHP.
Want to discuss your queries and interact with experts? You can connect with HellBound Bloggers (HBB) Facebook group for free!
Join HellBound Bloggers (HBB) and get Instant Updates. We'll also notify you with Great Deals, Discounts and other Interesting Tips. We won't SPAM or SHARE your Email Address with anyone.
YOU CAN ALSO SEARCH FOR YOUR DESIRED TOPICS:
Thank you for reading! We welcome and appreciate your comments, but at the same time, make sure you are adding something valuable to this article. If you have any serious queries, suggestions or anything related to this article, feel free to share them, we really appreciate that.
But, if your blog comments are a random "Thank you", "Useful Post", or anything that doesn't actually upscale the article, then we'll be removing them and it won't be appeared below. Thanks for understanding and thanks for connecting with us. If you want to give us any feedback or report any errors, you can kindly contact us and we'll revert back soon.
- Comments
- Facebook Comments
-
Comments
Leave a Reply
26 Comments
Facebook Comments
Rajesh Namase
Nice way to auto update copyright date, thanks.
Vincent Raja @ Tech2Hell
its quite easy and usefull … Well most blogs have automatic updates of this year…
like theme junkie… thanks pradeep…
Rohit Batra
this is quite Easy…thanks for the codes..
Saket Jajodia
Now a day people are becoming to lazy.. I dont want to be that much lazy.. but nice thing.. :p 😉
Rajasekar
NIce trick!
Programming Tutorials
I never thought to write a script to update the Copyright year because it`s fun to change it yourself, to think what you have done in a year
Dev | Technshare
nice…one…bro
.-= Dev | Technshare's last blog…<a href="http://www.technshare.com/tips-to-increase-page-rank/">8 Tips to Increase your Google Page Rank</a> =-.
Avinash D
So what would the relevant code be in Thesis?
S.Pradeep Kumar
Same I believe! These codes are common Avinash.. ! 🙂
Senthil Ramesh
I think the php coding of date (y) is enough for making the copyright year displayed. isnt it?
SEO Tips for Blogger
Anybody can add a copyright text on the footer of the page or i need to pay something to put a copyright text ?
S.Pradeep Kumar
You don’t need to pay for this… !
It is just a code ! So ..
Simran
Nice share buddy. It will help busy bloggers 🙂
S.Pradeep Kumar
Yup, and I’m sure, this will be useful to you ! 😀
Suneel
He he he Nice one there. Simple Javascript to do the needy.
DIdn’t get the thought of this until now 😉
S.Pradeep Kumar
Ha ha.. I thought of making this post.. when I was studying PHP ! 😀
Kaushik
Prefer using PHP People.
Javascript is not reliable as it runs in client side. Moreover, you can’t put this code in .htm(l) files in most of the servers as far as i know.
So better config the server to hav a common footer that runs in php 😉
S.Pradeep Kumar
I also prefer PHP code, but if the blogger uses a blog in .blogspot, then he should try only the JS code, since PHP is not supported there ! 😉
Tech-Freak Stuff
I recently moved from Blogger to WordPress! I will need this script now! Thanks a ton!
If you have any suggestions for a WordPress newbie like me, then feel free to tell me about it!
S.Pradeep Kumar
Glad you are happy with this script buddy ! 🙂
Suggestions ? 😀 Maybe.. redirect your blogger blog to wordpress… that can give you some extra traffic…
blinkky
Actually, I never though of this before. Thanks for remind me. I’ll take a look =)
S.Pradeep Kumar
Thanks Blinkky ! 😉
If you need any assistance.. feel free to ask.. !
Nik
Well, updating an year is not that annoying, a new year comes once in 365 days 😀
S.Pradeep Kumar
As time flies.. you may become a busy blogger… then little things like updating years will be an issue ! 😛
Sushant
Hmm thats a one good handy trick.
Sushant@webdire.com
S.Pradeep Kumar
Glad it helped you buddy ! 😉