We conducted an online survey and need to accurately calculate the time spent by participants. After using JavaScript and PHP, we found that the calculated time is not completely accurate.
The original script was sending server requests every 5 seconds to update the time in the database.
Upon further research, I discovered that setTimeOut and setInterval are not reliable for accuracy. Can anyone suggest a better way to tackle this issue?
I tried replacing the Ping function with another method that calculates the difference between previous timestamp packets and now(); however, it also proved to be inaccurate.
If anyone has any other solutions or suggestions to address this problem, please advise.