New course! Every coder should learn Generative AI!
Try a free lesson+ 1
How to create a timer in web page!!
and it should start when user enter the login button and it should stop when user press the logout, the time duration should be recorded !!
3 Answers
+ 3
int time;
var recorder = setInterval (function(){
time++;
},1000);
//to stop on logout.
clearInterval(recorder);
+ 2
*setInterval" is used. It won't be that difficult, try searching it.
+ 1
Save in your database or a flat file. When someone logs in, record the time (using time() function in PHP, outputs a time as UNIX format) and after logging out, record another time. The difference between these two numbers is your target (in seconds).