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

1 Answer

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

   
    
    
     
/*
run:
     
 
     
*/

 



answered Jun 26, 2021 by avibootz
...