Javascript examples for Date:setUTCSeconds
The setUTCSeconds() method sets the seconds of a date object, according to UTC time time.
UTC time is the same as GMT time.
date.setUTCSeconds(sec,millisec)
Parameter | Description |
---|---|
sec | Required. An integer representing the seconds |
millisec | Optional. An integer representing the milliseconds |
sec expected values are 0-59, but other values are allowed:
millisec expected values are 0-999, but other values are allowed:
A Number, representing the number of milliseconds between the date object and midnight January 1 1970
display seconds and milliseconds after changing both of them.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w. java2 s.c om var d = new Date(); d.setUTCSeconds(35, 825); var s = d.getUTCSeconds(); var ms = d.getUTCMilliseconds(); var x = document.getElementById("demo"); x.innerHTML = s + ":" + ms; } </script> </body> </html>