How To Get Yesterday Date Using Node Js?
Dec 15, 2021 . Admin

Hello Friends,
Now let's see example of how to get yesterday date example. We will check how to get yesterday date. This is a short guide on get yesterday date in node js. Let's get started with how to get yesterday date in node js.
Here i will give you many example how to get yesterday date 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 yesterdayDt = new Date(); yesterdayDt.setDate(yesterdayDt.getDate() - 1); console.log(yesterdayDt);
now you can simply run by following command:
node server.jsOutput :
2021-12-12T13:59:34.007Z
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
var datetime = require('node-datetime'); var timedt = datetime.create(); timedt.offsetInDays(-1); var yesterdayDt = timedt.format('Y-m-d H:M:S'); console.log(yesterdayDt);
now you can simply run by following command:
node server.jsOutput :
2021-12-12 19:37:35
It will help you...