Javascript examples for Date:setFullYear
Set the date to six months ago:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//ww w .j a v a 2 s. c om var d = new Date(); d.setFullYear(d.getFullYear(), d.getMonth() - 6); document.getElementById("demo").innerHTML = d; } </script> </body> </html>