Make Money Online Queries? Struggling To Get Traffic To Your Blog? Sign Up On (HBB) Forum Now!

HOW TO: Automatically Update The Copyright Year

CONNECT WITH HBB ON SOCIAL MEDIA

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.

READ
4 Things To Do When You Are Not Blogging


By

CEO and Founder of Slashsquare, Indian Blog Network and Web Consulting Media. HBB is a part of Slashsquare Network. I'm a Tech Blogger, Striving Entrepreneur, Atheist, and Proud Indian. Catch me on Facebook and Twitter.

  • My Website

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.

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
More in Blogging, Guides
Ways For Respecting Your Beloved Commentators

Close