check if a date is already over in javascript

index.tsx
// Create a new Date object for the desired date
const targetDate = new Date('2022-12-31');

// Get the current date
const currentDate = new Date();

// Check if the target date is in the past
if (targetDate < currentDate) {
    console.log('The target date is in the past');
} else {
    console.log('The target date is in the future');
}
340 chars
13 lines

related categories

gistlibby LogSnag