Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The setFullYear() Method</h2>
<p>setFullYear() sets the year of a date object.</p>
<p>Display the date six months ago:</p>
<p id="demo"></p>
<script>
const d = new Date();
d.setFullYear(d.getFullYear(), d.getMonth() - 6);
document.getElementById("demo").innerHTML = d;
</script>
</body>
</html>