"Have you got the time?" is ambiguous, which is why it can be a good idea to avoid using. It can mean 'have you got some time to spend (with me)". A cheeky person might answer "Yes, if you've got the inclination".
John's suggestion of 'Could you tell me the time please?' is good, but there are a few other options, such as 'do you know what time it is?' - again, a cheeky person might just answer 'yes!' to that one.
These days, that question is getting quite uncommon, as most people have a phone with the time on it.