Date.setSeconds() (Method)

Sets the seconds value of the time object.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:Time value
JavaScript syntax:-myDate.setSeconds(aSecondsValue)
- ( JavaScript 1.3 +)myDate.setSeconds(aSecondsValue, aMillisecondsValue)
Argument list:aMillisecondsValueAn optional value between 0 and 999 milliseconds
aSecondsValueA value between 0 and 59 seconds

The values are computed as local time coordinates.

ECMA mandates that the milliseconds value should be an optional argument. If the milliseconds value is omitted, the current milliseconds value is used as if the value had been supplied with a getMilliseconds() method.

The result of this method is the new time value of the containing object having been adjusted by the values passed in as arguments.

Example code:

   <HTML>

   <HEAD></HEAD>

   <BODY>

   <SCRIPT>

   myDate = new Date();

   myDate.setMilliseconds(0);

   myDate.setSeconds(0);

   myTime = myDate.getTime();

   document.write("The time rounded down to the nearest minute is "  + myTime + " Milliseconds");

   </SCRIPT>

   </BODY>

   </HTML>

See also:Date.getSeconds(), Date.prototype, Date.setUTCSeconds()

Cross-references:

ECMA 262 edition 2 - section - 15.9.5.26

ECMA 262 edition 3 - section - 15.9.5.30