Try this
Formula: copy to clipboard
="6:00"-MIN(TIMEVALUE("6:00"),B2)+MAX(TIMEVALUE("18:00"),C2)-"18:00"