JavaScript setSeconds()

The JavaScript date setSeconds() method sets the second value for the particular date on the basis of local time.

Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
dateObj.setSeconds(new_seconds);
dateObj.setSeconds(new_seconds);
dateObj.setSeconds(new_seconds);

Parameters:
new_seconds: Integer value between 0 to 59.

Example:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<body>
<script>
var bday =new Date("November 16, 1994 21:00:50");
document.writeln(bday.getSeconds() + "<br>");
bday.setSeconds(45);
document.writeln(bday.getSeconds());
</script>
</body>
</html>
<!DOCTYPE html> <html> <body> <script> var bday =new Date("November 16, 1994 21:00:50"); document.writeln(bday.getSeconds() + "<br>"); bday.setSeconds(45); document.writeln(bday.getSeconds()); </script> </body> </html>
<!DOCTYPE html>
<html>
<body>
<script>
var bday =new Date("November 16, 1994 21:00:50");
document.writeln(bday.getSeconds() + "<br>");
bday.setSeconds(45);
document.writeln(bday.getSeconds());
</script>
</body>
</html>