Home > Article > Web Front-end > Detailed explanation of the use of setSeconds() method in JavaScript_Basic knowledge
The javascript Date.setSeconds() method specifies the date according to the set seconds of the local time.
Grammar
Date.setSeconds(secondsValue[, msValue])
Note: The data inside and outside the brackets are optional
Here are the details of the parameters:
If the msValue parameter is not specified, the value returned from the method using getMilliseconds is used. If the specified argument is outside the expected range, calling setSeconds attempts to update the Date object's latest information accordingly. For example, if you use secondsValue with a value of 100, the minutes stored in the date object will be increased by 1, and 40 will be used for seconds.
Return value:
Example:
<html> <head> <title>JavaScript setSeconds Method</title> </head> <body> <script type="text/javascript"> var dt = new Date( "Aug 28, 2008 23:30:00" ); dt.setSeconds( 80 ); document.write( dt ); </script> </body> </html>
This will produce the following results:
Thu Aug 28 23:31:20 UTC+0530 2008