To check if a date's time matches either 00:00:00 or 23:59:59 using dayjs, you can use the format method to extract the time portion of the date and compare it to the desired values. Here's an example:
const date = dayjs('2022-01-01 00:00:00');
const time = date.format('HH:mm:ss');
if (time === '00:00:00' || time === '23:59:59') {
console.log('Time matches');
} else {
console.log('Time does not match');
}
In this example, we create a dayjs object from a date string that includes the time portion. We then use the format method to extract the time portion of the date in the format HH:mm:ss. We can then compare this time value to the desired values of 00:00:00 and 23:59:59 using an if statement. If the time matches either value, we log a message indicating that the time matches. Otherwise, we log a message indicating that the time does not match.