Ad Code

Auto Update Copyright Year in Html Website Dynamically

Website Copyright

The Copyright information on a website provides useful information about copyright ownership on the website content. It establishes the creator of that content and also the year the content was originally created. The Website copyright protects the owner‘s rights on the content, logos, images on the website.
The Copyright can be a single year which is the year the site was created. A range of years specifies the year of publishing through the year the content was last revised. If your website has been up for more than a year then it is advisable to show the date range instead of the current year.

Why should you update the Copyright Year?

Copyright information establishes your right over the content on your website. It is also important legally if you face the issue of content stolen from the website. An outdated copyright will no longer uphold your ownership of the site content making it vulnerable to thefts.
Displaying the correct range on the website copyright gives an idea of the time period the business has been running. An outdated copyright year would give a perception that the site is not maintained and information might not be accurate. An updated copyright helps establish visitor trust and strengthen the image of the site.

Format of Website Copyright Year

The Copyright information for a website is generally embedded inside its footer. The information usually consists of three elements:
  • The symbol ©, the word “Copyright,” or the abbreviation “Copr.”;
  • The year of launch or range since launch year of the website
  • The name, abbreviation, designation of the copyright owner.
How to update Copyright Year?
The website footer element contains the current year or range of years for which the website’s copyright is valid. You should auto update copyright year annually either manually or dynamically using a script or CMS.
  • Static Date Rewriting: You can manually update the copyright year on multiple web pages using a web authoring tool like FrontPage or Dreamweaver. The tool enables you to search and replace the old year with the current year.
  • Server-Side Scripting: You can add a PHP, JavaScript, ASP or Perl script to the server hosting the website. The scripts auto update the copyright date before loading the page.
  • Client Side Scripting: Scripts can be set up to run on the client machine using methods like JavaScript and Flash. This query the client machine for the current year. This is used to update copyright year while the website is being loaded.

How to Create a Dynamic Footer Date?

The primary requirement to generate the footer date dynamically is to be able to get the current year correctly. Following are some examples of code to retrieve the current year:
  • Get Current Year in PHP

php echo date(Y);?>
or
&copy;<? echo date(Y);?>
  • Get Current Year in JavaScript

<script type="text/JavaScript"> var theDate=new Date() document.write(theDate.getFullYear()) </script>
Here are some more alternate time-stamp display formats for both PHP and JavaScript. You can choose what fits better with your design.
  • F j, Y g:i a – February 08, 2016 12:50 pm
  • F j, Y –February 08, 2016
  • F, Y –February, 2016
  • g:i a – 12:50 pm
  • g:i:s a – 12:50:48 pm
  • l, F jS, Y – Wednesday, February 08, 2016
  • M j, Y @ G:i – Feb 08, 2016 @ 12:50
  • Y/m/d \a\t g:i A – 2016/02/08 at 12:50 PM
  • Y/m/d \a\t g:ia – 2016/02/08 at 12:50pm
  • Y/m/d g:i:s A – 2016/02/08 12:50:48 PM

Methods to Auto Update Copyright Year

Most of the websites these days are being built on WordPress or some other Content Management System. Earlier systems, however, continue to be on HTML websites. As such we take a look at the options available for the auto update of copyright year for both HTML and WordPress websites.

Auto Update Copyright Year in HTML

HTML websites need either a server side or a client side script to be able to display customised footer with the current date. Listed below are some pieces of code that you can add to your HTML code to auto update copyright year.

PHP:

Edit the HTML for the website to add PHP code that displays the current date in the copyright.
To add Simple date:
<?php echo date("Y"); ?>
To add Range of years:
<?php$fromYear = 2010;

$fromYear = 2010;

$thisYear = (int)date('Y');

echo $fromYear . (($fromYear != $thisYear) ? '-' . $thisYear : '');?>
JavaScript:
Edit the HTML for the website to add JavaScript code that displays the current date in the copyright.
To add Simple date:
<script type="text/JavaScript">

document.write(new Date().getFullYear());

</script>
to add Range of years:
2010<script>new Date().getFullYear()>2010&&document.write("-"+new

ate().getFullYear());</script>
Django:
Replace the Year in the footer files to the following:
{%now "Y"%}
node.js:
Change the footer date year in your Node.js by using the following code:
new Date().toISOString().substr(0,4)
ASP.NET (dot Net):
For Classic ASP or the ASP.NET websites replace the year in all the files or the common footer file with the below code:
Copyright @@ @DateTime.Now.Year

Post a Comment

0 Comments