Node.js date-and-time Date.addMinutes() Method
The date-and-time.Date.addMinutes() method is used to add the extra Minutes to the existing date and time.
Required Module: Install the module by npm or used it locally.
npm install date-and-time --save
<script src="/path/to/date-and-time.min.js"></script>
Syntax:
const addMinutes(dateObj, minutes)
Parameters: This method takes the following arguments as a parameter:
- dateobject: It is the string object of the date.
- minutes: It is the number of minutes to be added.
Return Value: This method returns updated date and time.
Example 1:
index.js
const date = require( 'date-and-time' )
const now = new Date();
const value = date.addMinutes(now,24);
console.log( "updated date and time :- " + value)
|
Run the index.js file using the following command:
node index.js
Output:
updated date and time :- Fri Mar 19 2021 18:38:26 GMT+0530 (India Standard Time)
Example 2:
index.js
const date = require( 'date-and-time' )
const now = new Date();
now.setDate(20)
const value = date.addMinutes(now,30);
console.log( "updated date and time :- " + value)
|
Run the index.js file using the following command:
node index.js
Output:
updated date and time :- Sat Mar 20 2021 18:04:43 GMT+0530 (India Standard Time)
Reference: https://github.com/knowledgecode/date-and-time#addminutesdateobj-minutes
Last Updated :
25 Mar, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...