Why

How

Date Handler

Calculate the date yesterday in JavaScript - Stack Overflow

var date = new Date();
date ; //# => Fri Apr 01 2011 11:14:50 GMT+0200 (CEST)
date.setDate(date.getDate() - 1);
date ; //# => Thu Mar 31 2011 11:14:50 GMT+0200 (CEST)

Get Yesterday Date in JavaScript | HereWeCode

// Create a date
const todayDate = new Date()
// Before subtracting 1 day
console.log(todayDate.toString())
// Output: "Tue Nov 15 2022 13:37:12 GMT+0100 (Central European Standard Time)"
// Subtract one day to the current date
todayDate.setDate(todayDate.getDate() - 1)
// After removing 1 day
console.log(todayDate.toString())
// Output: "Mon Nov 14 2022 13:37:12 GMT+0100 (Central European Standard Time)"

Compare two dates with JavaScript - Stack Overflow

var d1 = new Date();
var d2 = new Date(d1);
console.log(d1 == d2);   // prints false (wrong!)
console.log(d1 === d2);  // prints false (wrong!)
console.log(d1 != d2);   // prints true  (wrong!)
console.log(d1 !== d2);  // prints true  (wrong!)
console.log(d1.getTime() === d2.getTime()); // prints true (correct)

Checking if two Dates have the same date info - Stack Overflow

Date.prototype.isSameDateAs = function(pDate) {
return (
this.getFullYear() === pDate.getFullYear() &&
this.getMonth() === pDate.getMonth() &&
this.getDate() === pDate.getDate()
);
}

check if two dates are the same day in JavaScript (flaviocopes.com)

const datesAreOnSameDay = (first, second) =>
  first.getFullYear() === second.getFullYear() &&
  first.getMonth() === second.getMonth() &&
  first.getDate() === second.getDate();

Format a JavaScript Date to YYYY MM DD - Mastering JS

const date = new Date();
date.toLocaleDateString('en-GB').split('/').reverse().join(''); // '20211124'

Date.prototype.toLocaleDateString() - JavaScript | MDN (mozilla.org)

const date = new Date();
console.log(date);

How to Get the Current Date in JavaScript - Scaler Topics

let yourDate = new Date()
yourDate.toISOString().split('T')[0]

Format JavaScript date as yyyy-mm-dd - Stack Overflow

What

References