You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
417 B
14 lines
417 B
function isYesterday(date) {
|
|
if (!date) {
|
|
return false;
|
|
}
|
|
|
|
const dateObj = (typeof date === 'object') ? date : new Date(date);
|
|
const today = new Date();
|
|
const yesterday = new Date((today.setDate(today.getDate() - 1)));
|
|
|
|
return dateObj.getDate() === yesterday.getDate() && dateObj.getMonth() === yesterday.getMonth() && dateObj.getFullYear() === yesterday.getFullYear();
|
|
}
|
|
|
|
export default isYesterday;
|