Why time doesn't change | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why time doesn't change

In this code why setInterval function doesn't work. https://code.sololearn.com/wGGlDsCDMUPd/?ref=app

3rd Aug 2018, 12:56 AM
Satish Kumar Sharma
Satish Kumar Sharma - avatar
6 Answers
+ 4
The code in PHP is interpreted by the server and subsequently displayed, so it is not fully dynamic. You can create your code as WEB in Code Playground, that way it should work correctly.
3rd Aug 2018, 1:40 AM
Mickel
Mickel - avatar
+ 4
I found a method that works correctly in Code Plaground. It is quite easy to implement: https://code.sololearn.com/wc81Eq9LSykd/#php
3rd Aug 2018, 2:32 AM
Mickel
Mickel - avatar
+ 3
I tried some methods in PHP and none worked correctly. So I think it would be best to do it, in this case, using Javascript in the following way: https://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_clock
3rd Aug 2018, 2:07 AM
Mickel
Mickel - avatar
+ 3
PHP is server script runs on request and response events. Your JavaScript needs to keep requesting time information from server using api which is not the efficient way to perform since JavaScript could run its own clock from local device. The only time local needs to request time from server when the server acts as a master clock center or time server for time synchronisation across the devices.
3rd Aug 2018, 2:35 AM
Calviղ
Calviղ - avatar
+ 2
I have already know about js but I want to use server side (php) clock.
3rd Aug 2018, 2:09 AM
Satish Kumar Sharma
Satish Kumar Sharma - avatar
+ 1
How can I fix it.
3rd Aug 2018, 1:41 AM
Satish Kumar Sharma
Satish Kumar Sharma - avatar