Add a copyright year programmatically to your website footer


Especially in January, you start thinking about copyrights on your websites. This is one of those maintenance tasks ripe for a programmatic solution. No reason to manually update the years on your website’s copyright year after year. Here are a few good options for creating an automatically updating copyright year on your website.

JS script and HTML Div

myDiv = document.GetElementById("myDivId");
myDiv.innerHTML = month[day.getMonth()]; // you can add any HTML markup here
<div id="myDivId"></id>

Original inspiration from and the fix without javascript error.

Change copyright year automatically with inline Javascript

<p>Copyright &copy; <script>now=new Date(); year=now.getFullYear(); document.write(year);</script> Company Name</p>

PHP copyright year for WordPress PHP file

<p>&copy; <?php echo date('Y'); ?> Company Name</p>

About the author

Kelly Barkhurst

Designer to Fullstack is my place to geek out and share tech solutions from my day-to-day as a graphic designer, programmer, and business owner (portfolio). I also write on Arts and Bricks, a parenting blog and decal shop that embraces my family’s love of Art and LEGO bricks!

Add comment

Recent Posts