I could do this with php sessions, when the user visits your page it'll put the entry time in the session and when they exit it'll calculate up the time. this way you could store the time in a database if needed.
email me at
[email protected] if your interested.