I want to create a php countdown timer that runs for 6hours, the timer should continue running even when user logs out or logs in on a different computer.
Asked
Active
Viewed 487 times
-1
-
Are you using any database? If so, you can create a table with stores the initial time and the user id. So you can check it at every user interaction. – Mateus Felipe Apr 13 '17 at 18:32
-
2do you want also to stream "It's the final countdown" to the user ? I know I would want to hear it. – Gntem Apr 13 '17 at 18:32
-
1@Mr.Phoenix : I might be sacked for that, but it's worth it though ! so, please, [LMGIFY](https://www.youtube.com/watch?v=9jK-NcRmVcw) ^^ EDIT: BTW, am I the only one with that ***** song in his head now ? – OldPadawan Apr 13 '17 at 18:36
-
@OldPadawan no you are not i get it every time I read/hear the word countdown. – Gntem Apr 13 '17 at 18:40
1 Answers
1
If you need something dynamic (like showing the seconds changing in realtime) you should use Javascript. Actually, I think the best solution for you is to use PHP with Javascript. You can make a table on your database which has two columns, one storing the user ID (foreign key, unique key), and another storing the time it has been created. Then, in PHP you would check the the time and send it to the response.
On Javascript side, you would make a AJAX request to the countdown php script, and then display a counter-down based on what PHP has returned.
You can have a hint on these links:

Community
- 1
- 1

Mateus Felipe
- 1,071
- 2
- 19
- 43