How to add 10 seconds to a JavaScript date object?

JavascriptWeb DevelopmentFront End Technology

To add seconds to a JavaScript Date object, use the setSeconds() method. Under that, get the current seconds and add 10 seconds to it. JavaScript date setSeconds() method sets the seconds for a specified date according to local time.

You can try to run the following code to add 10 seconds to date.


 Live Demo

      <title>JavaScript setSeconds Method</title>
         var dt = new Date("December 30, 2017 11:20:25");
         dt.setSeconds( dt.getSeconds() + 10 );
         document.write( dt );


Sat Dec 30 2017 11:20:35 GMT+0530 (India Standard Time)
Published on 13-Feb-2018 08:36:22