There isn't a function like this.
And to suggest to make a script out of it, you simply suggest it, like you actually just did
There are two ways the script could work:
1) by analyzing the chatlogs of you and that contact. In that way you will also know how long you talked to that contact including previous chats in the past. And you will also be able to determine how long you have chatted with that person from date1 to date2... But this is very hard to do correctly.
2) A far more easier way is to use a script specific timer and store that value for each contact you talk to. With this you can't check how long you chatted between dates in the past, nor can you know how long you have chatted in the past. It will only work from the time you start using this script up to the current time.
But this is very easy to make...
So now, it is up to some developper to see this and to make it....