How To Use Date Sub Minutes Using Node Js?


Share:
 | Published By: Admin | Published On: Dec 29, 2021 | Category: Node JS


Hello Friends,

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

Here i will give you many example how to use date sub 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 subMin  = new Date("2021-3-19 09:40:20");
subMin .setMinutes( subMin .getMinutes() - 20 );

console.log( subMin.toLocaleString() );

now you can simply run by following command:

node server.js
Output :
19/3/2021, 9:20:20 addMin

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 subMin  = new Date();
subMin .setMinutes( subMin .getMinutes() - 25 );

console.log( subMin.toLocaleString() );

now you can simply run by following command:

node server.js
Output :
21/12/2021, 5:28:25 pm

It will help you...

Share: