I am traveling to the UK and my passport will have 6 months before expiring when I arrive but will be at 5 months when I leave. Will this be problem?
https://www.gov.uk/uk-border-control/before-you-leave-for-the-uk
You’re from outside the EU, Switzerland, Norway, Iceland or Liechtenstein
You must have a valid passport to enter the UK. It should be valid for the whole of your stay.
As long as it is valid when you arrive and valid when you leave the uk, you will be fine.
I would say that since it is the airline employees who are the primary enforcers of your travel documents, check with your airline. If a gate agent does not let you board the plane, it makes no difference what a British Immigration officer thinks. He/she is never going to see you.