Answers for "how to get 2 days back date in javascript"

5

How do I get the number of days between two dates in JavaScript

let today = new Date().toISOString().slice(0, 10)

const startDate  = '2021-04-15';
const endDate    = today;

const diffInMs   = new Date(endDate) - new Date(startDate)
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);


alert( diffInDays  );
Posted by: Guest on August-07-2021
1

javascript current date add 30 days

var future = new Date();
future.setDate(future.getDate() + 30);
Posted by: Guest on April-26-2020
0

new date() in javascript 3 days from now

var dt = new Date();
dt.setDate(dt.getDate() + 3);
Posted by: Guest on July-08-2020

Code answers related to "how to get 2 days back date in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language