Auto Update Copyright Year in a Website Dynamically using JavaScript & php (2022)


Preparing your websites for the New Year or revising the content? Feel like updating of copyright year is a monotonous and tedious task? Look at some of the approaches for updating copyright year automatically without hassle!

The Website Copyright adds ownership to the site content and it is crucial to reinstate it every year. An updated copyright not only shows that the site is maintained but also gets it rated high on SEO search lists. An annual task for all website owners is to update the copyright year across websites. As a webmaster, you may find it a frustrating task to do it on time year after year. Let us explore some of the ways to auto update the copyright year on a website.

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 to 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 year 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 year helps establish visitor trust and strengthen the image of the site.

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.


Auto Update Copyright Year in HTML using Javascript

Add this code at the ending tag of body :


            var year_started = 2021;  // The year the company/web started
            var dt = new Date();      // Using JavaScript Date Function we get TODAY'S DATE
            var year_now = dt.getFullYear();  // We get JUST the year from our full date

            if(year_now == year_started){    // With If Conditionals we look if the year we started company is the same as today's year
                var copyr = "Your Comp. © " + year_started;   // IF YES we return this STRING, with just the copyright and the year we started
            else{      // We can use ELSE for the OTHER OPTIONS;
                var copyr = "Your Comp. © " + year_started + "-" + year_now;  //  If the year is not the same as the started year we return this string

            document.getElementById("copyright").innerHTML = copyr; // Using "document.getElementById("copyright").innerHTML" we sent this string to the paragraph element with ID="copyright" in HTML



Auto Update Copyright Year in HTML using php

Using php we can add Range of years:


            $started_year = 2021; // The year the company/web started
            $year_now = date('Y'); // Using php Date Function we get the TODAY'S YEAR
           if($started_year == $year_now){ 

     <p class="copyright" id="copyright"><?php echo "Your Comp. © ".$started_year ?></p>
                 } else{

     <p class="copyright" id="copyright"><?php echo "Your Comp. © ".$started_year."-".$year_now ?></p>



Have a look at website:

Get the files: