isToday
A utility function to check if a given date is the current day.> isToday(date: Date): boolean
- date: The date to compare against today's date.
- Returns: `true` if the given date matches today's date, `false` otherwise.
Example
import { isToday } from "@explita/daily-toolset";
// Check if today is the given date
const today = new Date();
console.log(isToday(today)); // true
// Check with a past date
const yesterday = new Date();
yesterday.setDate(today.getDate() - 1);
console.log(isToday(yesterday)); // false
// Check with a specific date
const specificDate = new Date("2024-11-22");
console.log(isToday(specificDate));
// true or false depending on the given date
Use Cases
- Validating if an event date is today.
- Determining if a timestamp falls within the current day.
- Filtering or sorting dates based on their relation to today.