Just select the cells in column B that you want to apply it to (I am assuming there is a header row, so let's use row 2), and enter the following Conditional Formatting formulas:
Condition 1
Formula: =$B2-$A2 > 4
Format color: red
Condition 2
Formula: =$B2-$A2 < 4
Format color: green
NOTE: If it is possible that one of these dates may not be populated, we may need to account for that, depending on what your requirements are.
If you only want the Conditional Formatting to be applied if both dates are populated, you could do it like this (for Condition 1):
=AND($A2 > 0,$B2 > 0,$B2-$A2 > 4)
(Condition 2 would follow similar structure logic)