As you can see from the physics of rainbow applet. If the sun ray is coming horizontally(near sunrise or sunset), you will see rainbow at about 40-42 degree. If it is one hour earlier than sunset or one hour later than sunrise: The angle of sun ray will be 360/24=15 degree, so the rainbow will be observed at 55-57 degree. So you would not be able to see rainow from the sun ray if it is 3 hours before sunset or 3 hours after sunrise. (unless you are located at a high place -e.g. on top of a mountain , and looking down).