Because I understand that a passport has to be valid for some time after arriving in Spain (in case you are not able to travel back for any reason) I am trying to find how many months that is.
But when you get back why don't you renew your passport then. You can do this when there is still nine months left to run on your passport and the remaining months are credited to your new passport. http://www.passport.gov.uk/passport_renewing_w hen.asp