' Il metodo setFullYear () imposta l'anno di un oggetto data:
https://www.w3schools.com/js/tryit.asp?filename=tryjs_date_setfullyear <!DOCTYPE html> <html> <body> <h2>JavaScript setFullYear()</h2> <p>The setFullYear() method sets the year of a date object:</p> <p id="demo"></p> <script> var d = new Date(); d.setFullYear(2020); document.getElementById("demo").innerHTML = d; </script> </body> </html> 'Il metodo setFullYear () puo' facoltativamente impostare mese e giorno. 'Si prega di notare che il mese conta da 0. Dicembre e' il mese 11: 'Gio 03 dicembre 2020 16:30:36 GMT + 0100 (Ora standard centrale centrale) https://www.w3schools.com/js/tryit.asp?filename=tryjs_date_setfullyear_options <!DOCTYPE html> <html> <body> <h2>JavaScript setFullYear()</h2> <p>The setFullYear() method can optionally set month and day.</p> <p>Please note that month counts from 0. December is month 11:</p> <p id="demo"></p> <script> var d = new Date(); d.setFullYear(2020, 11, 3); document.getElementById("demo").innerHTML = d; </script> </body> </html> |