How to create a timer in web page!! | Sololearn: Learn to code for FREE!
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 !!

12th Oct 2017, 5:03 PM
Deekshith K
Deekshith K - avatar
3 Answers
+ 3
int time; var recorder = setInterval (function(){ time++; },1000); //to stop on logout. clearInterval(recorder);
12th Oct 2017, 5:07 PM
Niush
Niush - avatar
+ 2
*setInterval" is used. It won't be that difficult, try searching it.
12th Oct 2017, 5:05 PM
Niush
Niush - avatar
+ 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).
12th Oct 2017, 9:04 PM
$machitgarha
$machitgarha - avatar