We say 'What time is it?' ( or 'What's the time?') if we know that the other person has a clock, phone, computer screen or other device to hand - that all they need to do is look at it.
We say 'Do you have the time?' if you are not sure whether the person has any of the above to hand. The person might say 'No, I don't. I left my watch at home. But I guess it's about 8 o'clock.'
Obviously, in other contexts, 'Do you have the time?' means 'Do you have the time (to spare to do something)?' - as in 'I'll help you' 'Do you have the time?' 'Yes, I've got plenty of time. I don't need to go into work until this afternoon.'
Just curious..your profile says you're a native English speaker. Why are you asking this question?