<!DOCTYPE html>
<html>
<body>
<p>Click the button to display the date six months ago.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var d = new Date();
d.setUTCFullYear(d.getUTCFullYear(), d.getUTCMonth() - 6);
document.getElementById("demo").innerHTML = d;
}
</script>
</body>
</html>