How To Use Date Add Minutes Using Node Js?

Dec 28, 2021 . Admin



Hello Friends,

Now let's see example of how to use date add minutes example. We will check how to use date add minutes. This is a short guide on use date add minutes in node js. Let's get started with how to use date add minutes in node js.

Here i will give you many example how to use date add minutes using node js.

Example 1 :

Step 1 : Create Node App

Run following command to create node app.

mkdir my-app
cd my-app
 
npm init
Step 2 : Create server.js file

server.js

var addMin  = new Date();
addMin .setMinutes( addMin .getMinutes() + 30 );

console.log( addMin.toLocaleString() );

now you can simply run by following command:

node server.js
Output :
21/12/2021, 6:13:09 pm

Example 2 :

Step 1 : Create Node App

Run following command to create node app.

mkdir my-app
cd my-app
 
npm init
Step 2 : Create server.js file

server.js

var addMin  = new Date("2021-10-20 10:10:20");
addMin .setMinutes( addMin .getMinutes() + 30 );

console.log( addMin.toLocaleString() );

now you can simply run by following command:

node server.js
Output :
20/10/2021, 10:40:20 am

It will help you...

#Node JS