I've a dateTime string - '2020-04-30 07:00:00'. I need to extract the time '07:00:00' and check if it is less than or equal to '11:30' hrs.
How do I do that in easiest way?
I've a dateTime string - '2020-04-30 07:00:00'. I need to extract the time '07:00:00' and check if it is less than or equal to '11:30' hrs.
How do I do that in easiest way?
Parse your string to a date:
const d = new Date(Date.parse('2020-04-30 07:00:00'))
Test whatever you want:
if (d.getHours() < 11 || (d.getHours() === 11 && d.getMinutes() <= 30)) {
// earlier than 11:30 or 11:30
}