Answers for "get previous date in javascript"

3

js yesterday date

var yesterday = new Date((new Date()).valueOf() - 1000*60*60*24);
Posted by: Guest on October-29-2020
2

js yesterday date

var d = new Date();
d.setDate(d.getDate() - 1);
Posted by: Guest on October-29-2020
0

set a previous year to the current date in javascript

const d = new Date();
d.setFullYear(d.getFullYear()-1);

console.log(d.toDateString()); // "Fri Oct 04 2019"
Posted by: Guest on August-29-2021
0

get previous year in javascript

const currentYear = new Date().getFullYear(); // 2020

const previousYear =  currentYear-1;

console.log(previousYear); // 2019
Posted by: Guest on August-29-2021

Code answers related to "get previous date in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language