Desperate need of help, how do you calculate elapsed time?

Results 1 to 2 of 2

Thread: Desperate need of help, how do you calculate elapsed time?

  1. #1
    Join Date
    Dec 1969
    Posts
    144

    Default Desperate need of help, how do you calculate elapsed time?

    here is my problem:<BR>user clicks on an asp page, then 2 minute and 44 seconds later the user clicks a link out of the page. How do you calculate how long the user was on the first page and write the calculated time to the second pag?<BR>Please help?<BR>Thanks,<BR>Ray

  2. #2
    Join Date
    Dec 1969
    Posts
    760

    Default RE: Desperate need of help, how do you calculate elapsed time?

    Ray,<BR>The only way I can think of is the following:<BR>Say the user hits a particular page. This page, of course is an .asp page. At the very bottom of it, I&#039d put the follwing code. <BR>&#060;%<BR>&#039first get the name of current page<BR>DIM curPage<BR>curPage = Request.ServerVariables("HTTP_SCRIPT_NAME")<BR>&#0 39check this against your session variable<BR>&#039if they&#039re not equal, then you know you should update you date<BR>&#039in another session var<BR>If (Session("CurPage") &#060;> curPage) Then<BR> &#039since we&#039re here, you know that the page has changed<BR> &#039the Session("CurPage") is either empty or contains the <BR> &#039name of the page the user visited just before this one.<BR> &#039if it does contain the name of the previous page, then<BR> &#039it should also have the time when that page was visited<BR> &#039you can simply get the current time by using the Now function<BR> &#039and subtracting the saved time. This will give you a pretty <BR> &#039accurate time (give or take a few seconds) Now you have the &#039just visited page and the time the user spent on it. Save to &#039DB or whatever here...<BR><BR> &#039assign new page (current page) to session var<BR> Session("CurPage") = curPage<BR> &#039keep track of the time the user has hit the page<BR> Session("StartTime") = Now<BR>End If<BR><BR>I&#039ve probably confused the hell out of you with that unorganized explanation. Try to make sense of it and I hope it helps.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •