Set the date to six months ago, UTC time: - Javascript Date

Javascript examples for Date:setUTCFullYear

Description

Set the date to six months ago, UTC time:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials