You’ll find lots of useful advice about travelling abroad on the government website, including how long your passport needs to be valid depending on where you're going. Select the country you're planning to visit and check their “Entry requirements” with plenty of time before you travel.
You may need to renew your passport earlier than expected, depending on the country you're planning to visit.
On long haul flights, you also need to consider whether you’ll be transiting another country on the way. Be sure to check the entry requirements for that country, too.
If your passport doesn’t comply with the entry requirements of your destination, you could be denied boarding at the airport.