Javascript examples for Date:setUTCFullYear
Set the date to six months ago, UTC time:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from ww w .jav a 2s . com var d = new Date(); d.setUTCFullYear(d.getUTCFullYear(), d.getUTCMonth() - 6); document.getElementById("demo").innerHTML = d; } </script> </body> </html>