Pregnancy tests

Hello
How early and how long should you take a pregnancy test? Does taking them in the morning or later in the day make a difference?