How to display the previous year in a webpage using HTML and JavaScript

1 Answer

0 votes
<div>
   <p id="yearid"></p>
</div>
 
 
 
<!--
 
2020
 
-->
const dt = document.getElementById('yearid');
 
dt.textContent = new Date().getFullYear() - 1;

   
    
    
     
/*
run:
     

     
*/

 



answered Jun 26, 2021 by avibootz
...