Answers for "date - 1 day js"

15

add 1 day to date js

let date = new Date();
// add a day
date.setDate(date.getDate() + 1);
Posted by: Guest on June-08-2020
0

is date 1 day ago javascript

function daysSinceGivenDate (date) {
  const dateInSeconds = Math.floor((new Date().valueOf() - date.valueOf()) / 1000);
  const oneDayInSeconds = 86400;

  return (dateInSeconds / oneDayInSeconds) | 0; // casted to int
};

console.log(daysSinceGivenDate(new Date())); // 0
console.log(daysSinceGivenDate(new Date("January 1, 2022 03:24:00"))); // relative...
Posted by: Guest on January-10-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language