setSeconds()
Date
instance method setterS2C Home
« Globals « Date « setSeconds()
Description
Sets the locale specific second of the minute (0-59) for the specified date.
Syntax
Signature | Description |
---|---|
aDate.setSeconds(secondsInt[, millisecondsInt]) | Sets the locale specific second of the minute (0-59) for the specified date. |
Parameters
Parameter | Description |
---|---|
secondsInt | An integer in the range 0-59. |
millisecondsInt | An integer in the range 0-999.
|
For specified values outside the ranges above the setSeconds() method will try and set the date accordingly. |
Examples
The code below shows an example of the setSeconds()
method of Date
.
// Create a Date instance for the current date and time.
var todaysDate = new Date();
alert(todaysDate);
// Set seconds.
todaysDate.setSeconds(59);
alert(todaysDate + ' - Seconds set to 59');
Related Tutorials
JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times