25% off ProSNIPC25OFF

Current Year Auto-Update

Replaces the text content of elements with class current-year or a data-current-year attribute with the live year.

JavaScriptby SnipCraft
js
(function () {
  'use strict';

  document.addEventListener('DOMContentLoaded', function () {
    var year = String(new Date().getFullYear());
    document.querySelectorAll('.current-year, [data-current-year]').forEach(function (el) {
      el.textContent = year;
    });
  });
})();
#copyright#date#footer#javascript#utility