How To Date Add Month Using Node Js?
Dec 21, 2021 . Admin
Hello Friends,
Now let's see example of how to date add month example. We will check how to date add month. This is a short guide on date add month in node js. Let's get started with how to date add month in node js.
Here i will give you many example how to date add month using node js.
Example 1 :
Run following command to create node app.
mkdir my-app cd my-app npm initStep 2 : Create server.js file
server.js
var addMonth = new Date("November 27, 2020 11:30:25"); addMonth.setMonth( addMonth.getMonth() + 1 ); console.log( addMonth );
now you can simply run by following command:
node server.jsOutput :
2020-12-27T06:00:25.000Z
Example 2 :
Step 1 : Create Node AppRun following command to create node app.
mkdir my-app cd my-app npm initStep 2 : Create server.js file
server.js
let addMonth = new Date(); let finalDate = new Date(addMonth.setMonth(addMonth.getMonth() + 1)); console.log(addMonth);
now you can simply run by following command:
node server.jsOutput :
2022-01-15T12:02:52.139Z
It will help you...