Of all the borders I have crossed, the UK tends to be the most stringent and asks the most questions, wanting details as to your plans.
What you are proposing is technically correct, just keep in mind the following:
- Know the date you will be exiting, better yet have a ticket.
- Have the address of where you will be staying
- Be ready to relate your plans, have an itinerary.
As others have mentioned, it is Up to 6 Months, entry and length of stay is at the discretion of the border agent, but regardless of what you say, the stamp they use allows up to 6 months, only if they take exception will the time be shorter.
Watch your times carefully so you do not go afoul of limits. You actually could head to Spain at any time, do a stretch and head back to the UK (or Ireland), it is 6 months based on any entry, though they may limit you if they see multiple exits and entries.