HOW TO: Automatically Update The Copyright Year

Written by in Blogging, Tutorials - Print This Post



Copyright-YearManually 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>&copy; 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

&copy; 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

&copy; 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.




HBB RSS
Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic. You will also get instant access to 100+ HBB Guides & Tutorials.
If you wish to subscribe here via Email, then kindly click here.


Connect with HBB on Facebook Easily




Editor-in-Chief and Owner of 20 Years Old Kiddo, Open Source Enthusiast, Tech Blogger, Striving Entrepreneur, and a Typical Engineering Student. Addicted to Blogging, Walking and Messing. Catch him on Facebook, Twitter and .


HBB has 551+ Awesome Contributors. [Join HBB].

HellBound Bloggers (HBB) is a part of Slashsquare Network.







25 Responses to “HOW TO: Automatically Update The Copyright Year”

Leave a Reply


Comments Policy | Brand Your Comments | Do Follow Blog | Top Commentators Award


REFERENCE : 7 Tips To Be A Hero On Blog Commenting [HELPFUL]


Overall HellBound Bloggers (HBB) has 22,103 Genuine Comments and Yours Will Add More Value To It.




Previous Article:

Next Article:

  1. Sushant says:

    Hmm thats a one good handy trick.

    Sushant@webdire.com

  2. Nik says:

    Well, updating an year is not that annoying, a new year comes once in 365 days :D

  3. blinkky says:

    Actually, I never though of this before. Thanks for remind me. I’ll take a look =)

  4. 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!

  5. Kaushik says:

    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 ;)

  6. Suneel says:

    He he he Nice one there. Simple Javascript to do the needy.

    DIdn’t get the thought of this until now ;)

  7. Simran says:

    Nice share buddy. It will help busy bloggers :)

  8. Anybody can add a copyright text on the footer of the page or i need to pay something to put a copyright text ?

  9. I think the php coding of date (y) is enough for making the copyright year displayed. isnt it?

  10. Avinash D says:

    So what would the relevant code be in Thesis?

  11. 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> =-.

  12. 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

  13. Now a day people are becoming to lazy.. I dont want to be that much lazy.. but nice thing.. :p ;)

  14. Rohit Batra says:

    this is quite Easy…thanks for the codes..

  15. its quite easy and usefull … Well most blogs have automatic updates of this year…
    like theme junkie… thanks pradeep…



Subscribe without commenting




COPYRIGHT © 2011 SLASHSQUARE NETWORK. REPRODUCTION WITHOUT EXPLICIT PERMISSION IS PROHIBITED. ALL RIGHTS RESERVED.

Slashsquare
Mobile Version · About Us · Contact Us · Subscription · Advertise · Review · Write For Us · Archives · Privacy Policy · Disclaimer
Loading...