It's been lovely having you here. (Is this sentence said when it's almost time for someone to leave a place?)
It has been lovely having you here.
The tense is has+pp (present perfect), which means something happend in the past and continued until now or finished now. So the person was there in the past and now he/she is going to leave and the conversation partner says "It has been lovely having you here."?