This JavaScript code below is an event listener that executes when the DOM (Document Object Model) is fully loaded and ready.
Here's an explanation of how it works:

  1. The code is wrapped within the DOMContentLoaded event listener, which triggers when the HTML document has been completely loaded and parsed.

  2. Inside the event listener, a Date object is created using new Date(). This object represents the current date and time.

  3. The getFullYear() method is called on the Date object to retrieve the current year as a four-digit number.

  4. The next line selects an HTML element with the ID "current-year" using document.getElementById('current-year'). This assumes that there is an HTML element in the document with the ID "current-year" (e.g., <span id="current-year"></span>).

  5. The textContent property is used to set the content of the selected element to the value of the year variable, which contains the current year.

  6. When the DOM is fully loaded, the event listener triggers, and the current year is inserted into the HTML element with the ID "current-year".

To use this code, follow these steps:

  1. Add an HTML element with the ID "current-year" to the appropriate location in your HTML markup. For example: <span id="current-year"></span>.

  2. Place the given JavaScript code within a <script> tag either in the head section or just before the closing body tag of your HTML document.

<!DOCTYPE html>



  <!-- Other head elements  - -->


    document.addEventListener('DOMContentLoaded', function() {

      var year = new Date().getFullYear();

      var yearElement = document.getElementById('current-year');

      yearElement.textContent = year;





  <!-- Rest of your HTML content -->

<footer class="footer">
<div class="row">
<div class="col-sm-8">
<p class="footerleft"> <a href="/terms-of-use">Terms of use</a> | <a href="/privacy-policy">Privacy policy</a> | <a href="/contact">Contact</a>
<div class="col-sm-4">
<p>Wordpress Functions - <span id="current-year"></span></p>



When the page is loaded, the JavaScript code will be executed, and the element with the ID "current-year" will be updated with the current year.