Set the time to 48 hours ago, using UTC methods: - Javascript Date

Javascript examples for Date:setUTCHours

Description

Set the time to 48 hours ago, using UTC methods:

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 w ww  .  j  a  v a2s  .c o  m
    var d = new Date();
    d.setUTCHours(d.getUTCHours() - 48);
    document.getElementById("demo").innerHTML = d;
}
</script>

</body>
</html>

Related Tutorials