Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

auto update copyright year javascript

<div class="copyright">
  <footer>Copyright © <span id="year"></span> , All rights reserved to X</footer>
</div>
<script>
  
  function getCurrentYear() {
    return new Date().getFullYear(); // returns the year via local timing
  };

  document.getElementById("year").innerHTML = getCurrentYear(); 
  //changing the inner html of the span with "year" id to the given year(2021)
</script>
 
PREVIOUS NEXT
Tagged: #auto #update #copyright #year #javascript
ADD COMMENT
Topic
Name
4+2 =