Skip to main content
@spa-tools/utilities

isYesterday()

The isYesterday() function checks if a date value equates to a date that is yesterday.

Usage

import { isYesterday } from '@spa-tools/utilities';

const todayDate = new Date();
todayDate.setDate(todayDate.getDate() - 1);
console.log(isYesterday(todayDate));
// --> true

console.log(isYesterday('2080-12-31'));
// --> false

Arguments

NameTypeRequired?Description
datestring | number | DateyesThe date value to check as either date string, timestamp integer, or date object

Returns

boolean - If value of date equates to a date that is yesterday then returns true else returns false.