On/Off Entity based on now being equal to an sensor value

I have a sensor that returns values like:

2022-11-21T04:00:00Z

How can I check that date & time (ISO)

2022-11-20T16:59:00

is within a 3 hour window after the sensor time? i.e. turn on a device for the 3 hours after the sensor time/date

Thanks