How to Auto Update Copyright Year on Your Website

Posted on: Dec 15, 2023

2 mins read


Copyright is a legal concept that grants the creator exclusive rights to their original work. Updating the copyright year reflects the latest claim, ensuring accurate protection and signaling the content's ongoing relevance and maintenance.

How to Auto Update Copyright Year on Your Website

Code

html
<body>
<p>
All Rights Reserved,
<span id="currentYear"></span>
<a href="https://tech.timonwa.com">Timonwa Akintokun</a>.
</p>
<script>
let date = new Date().getFullYear();
document.getElementById("currentYear").textContent = date;
</script>
</body>

For HTML projects, you can use the above code snippet to update the year automatically on your website.

jsx
const Footer = () => {
let date = new Date().getFullYear();
return (
<p>
All Rights Reserved, {date}.{" "}
<a href="https://tech.timonwa.com">Timonwa Akintokun</a>.
</p>
);
};

You can use the above code snippet for React projects to automatically update the year on your website.

Explanation

The JavaScript Date() object captures the current date and time. Afterward, the getFullYear() method extracts the current year from the obtained date and time. The identified year is stored in a variable named date.

Updating the copyright year is more than just a legal formality; it is a crucial indicator of your commitment to maintaining and protecting your content. Here's why keeping the copyright year current is essential:

  1. Accurate Protection: A current copyright year ensures that you accurately claim protection for your original work, providing a clear timeframe for your exclusive rights.

  2. Relevance Signaling: A recent copyright year signals to your audience that your content is up-to-date and relevant. It shows that you actively manage and maintain your website.

  3. Legal Compliance: Regularly updating the copyright year demonstrates your commitment to legal compliance, reinforcing your dedication to respecting intellectual property laws.

By incorporating the provided JavaScript snippet into your website's footer, you automate the process, ensuring that your copyright year is always current without manual intervention.

Connect with Me

Did you find this article helpful? I'd love to hear your thoughts or answer any questions!

πŸ”— Connect with me on LinkedIn or follow me on X(formerly Twitter) for daily tips and updates

βœ‰οΈ Subscribe to my Newsletter for weekly dev insights

πŸ‘©β€πŸ’» Check out my open source projects on GitHub

β˜• Buy Me a Coffee if this article helped you

❀️ Become a GitHub Sponsor to support my open source work

🀝 Visit my Sponsorship page or Affiliate Links page for more ways to support me

Happy coding! πŸš€

Simplify your workflow with free, ready-to-use Notion templates!

Subscribe to my newsletter πŸ’Œ

Stay in the loop on the latest articles, tutorials, projects, and exclusive content focused on web development! πŸ’»πŸ“šβœ¨