Javascript examples for Date Operation:Year
Create Date from year, month day
<html> <head></head> <body> <p>Click the button to display the full year of todays date.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() {// ww w. j av a2 s .co m var my = "2-5"; var month = my.split("-")[0]; var day = my.split("-")[1]; var year = new Date().getFullYear(); let gdday = new Date(year, month, day); document.getElementById("demo").innerHTML = gdday; } </script> </body> </html>