Tired of replacing the new year in the copyright footer every year?

Raj Karan
2 min readMay 15, 2021

Well, almost every website in the world has this footer for sure. And, most of them are tired of updating it every year and some of them are still showing the footer with the last decade.

Updating date every year is not limited to the website only but to desktop applications and other software products as well that show the same footer text.

Solution

Let’s switch this static text to a dynamic one by using Date API, which I believe almost every programmer knows very well.

Sharing with you an example of Date API in javascript.

new Date().getFullYear(); // gets current year

Now, just use this with static text and forget to update it every year.

new Date().getFullYear(); | All Rights Reserved

And, of course, this is how the date range looks like.

const previousYear = new Date().getFullYear() -1;

const currentYear= new Date().getFullYear();

Copyright 20XX - 20X1 | All Rights Reserved

Copyright {previousYear} - {currentYear} | All Rights Reserved

Isn’t that simple and a one-time effort?. But make sure the machine you are running your web app or software has the correct date and time. Since it is a small post, but even a small effort makes a difference, then it is worth sharing.

--

--

Raj Karan
0 Followers

Simple Engineer with so many ideas 💡