Always keep the year current

Tag name
Use a simple script to keep your copyright year (or any year) up to date. Create a class on a text span, get the current year, and replace the text content by following the steps below.

Step 1

Highlight some text, and wrap it in a span. Give the span a class, e.g. '.display-year', so that we can grab it later with the code. Add this class to all the text elements where you want to display the current year.

Step 2

Create a constant that finds all the elements with the class you just created:

Or simply copy paste this snippet, and add your custom class (e.g. '.display-year')  to any span you'd like to display the year.

Need it on a single page? Add it to the head of that page's custom code section.

Need it on every page? Add it to the custom code head section in site settings.

<!-- get current year -->
<script>document.addEventListener("DOMContentLoaded", function() { 
  	const yearSpan = document.querySelector('.display-year');
  	const currentYear = new Date().getFullYear();
  	yearSpan.textContent = currentYear;

Unlock your website business

Let's kickstart this exciting journey with an obligation-free initial consultation. Click below to contact, or send an email to