Set both the seconds and milliseconds: - Javascript Date

Javascript examples for Date:setSeconds

Description

Set both the seconds and milliseconds:

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 .ja va2 s . c  o m
    var d = new Date();
    d.setSeconds(35, 825);
    var s = d.getSeconds();
    var ms = d.getMilliseconds();
    var x = document.getElementById("demo");
    x.innerHTML = s + ":" + ms;
}
</script>

</body>
</html>

Related Tutorials