How to add 30 minutes to a JavaScript Date object?

JavascriptWeb DevelopmentFront End Technology

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

Example

You can try to run the following code to add 30 minutes to date.

 Live Demo

<html>
   <head>
      <title>JavaScript setMinutes Method</title>
   </head>
   <body>
      <script>
         var dt = new Date();
         dt.setMinutes( dt.getMinutes() + 30 );
         document.write( dt );
      </script>
   </body>
</html>

Output

Sat Dec 15 2018 12:18:47 GMT+0530 (India Standard Time)
raja
Published on 13-Feb-2018 08:32:26
Advertisements