Pregnancy?

This might sound dumb but whatever people has been telling me that you can only get pregnant on your  fertile days but i have also heard you can get pregnant anytime but I just wanted know which one is true?