0

How to track the time of a user, spent on a web page?

I am creating a quiz. The user can access the quiz for unlimited times. I want to get the time duration of the each user and the number of attempts to show it to the user.

13th Oct 2018, 2:08 PM
Tharindu Sankalpa
Tharindu Sankalpa - avatar
3 Antworten
+ 1
Make a start button which gets the current time in milliseconds from 1970 (new Date().getTime()). Then an end button which does it again. Take away the first time from second and turn it into seconds (/1000).
13th Oct 2018, 2:35 PM
TurtleShell
TurtleShell - avatar
+ 1
It's obviously simplified but should give you the general idea: https://code.sololearn.com/WWrf0POBosRN/?ref=app
13th Oct 2018, 3:55 PM
TurtleShell
TurtleShell - avatar
0
TurtleShell would you be able to give me a simple code if you don't mind.
13th Oct 2018, 3:19 PM
Tharindu Sankalpa
Tharindu Sankalpa - avatar