As a freelancer managing multiple client sites I was looking for an easy way to dynamically display the current year in the footer of all my sites. There are other forum posts about how to do this, but some don’t work if there are multiple instances of the current year span on the same page, and some were just overly complicated for my needs so I wanted to share this new simple method I’m using.
Step 1: Paste this code before the body tag in your project settings
This is so helpful! Do you know how to display a month in advance? For example, if it’s currently February, I’d like to have the span text on the site say March.
To contribute to this topic i suggest use vanilla javascript:
<script>
const systemDate = new Date(); // Current date
let currentYearText = document.querySelector(".current-year") // Select class
currentYearText.innerHTML = systemDate.getFullYear(); // Apply current date (only year) into select class
</script>
IMPORTANT: Add custom code in site settings (in dashboard - settings icon) > Custom code > Footer Code