almystersv Posted January 13, 2008 Share Posted January 13, 2008 Hi Guys, Is there anyway to update the system time i have displayed on my page without refreshing the whole page?! Or is there a better way to show the time? Quote Link to comment https://forums.phpfreaks.com/topic/85743-solved-refreshing-clock-but-not-page/ Share on other sites More sharing options...
tinker Posted January 13, 2008 Share Posted January 13, 2008 look into ajax Quote Link to comment https://forums.phpfreaks.com/topic/85743-solved-refreshing-clock-but-not-page/#findComment-437598 Share on other sites More sharing options...
p2grace Posted January 13, 2008 Share Posted January 13, 2008 You actually don't need ajax just to show the time (you can of course if you want to), but you could also just use a simple javascript function. Quote Link to comment https://forums.phpfreaks.com/topic/85743-solved-refreshing-clock-but-not-page/#findComment-437609 Share on other sites More sharing options...
tinker Posted January 13, 2008 Share Posted January 13, 2008 where he states system time, I took it as server time. Personally I prefer just the served time, then it acts as a record. Quote Link to comment https://forums.phpfreaks.com/topic/85743-solved-refreshing-clock-but-not-page/#findComment-437628 Share on other sites More sharing options...
twostars Posted January 13, 2008 Share Posted January 13, 2008 Using AJAX would be much more accurate, as the time served by a simple javascript script, can get disrupted. I've had that before, and its not pretty. AJAX would ensure its the CORRECT time at all times. Quote Link to comment https://forums.phpfreaks.com/topic/85743-solved-refreshing-clock-but-not-page/#findComment-437693 Share on other sites More sharing options...
Lukela Posted January 13, 2008 Share Posted January 13, 2008 AJAX is the answer, but I dont think he knows AJAX... do you? because a person who has knowledge in AJAX would know that PHP can refresh a certain part of the code. Quote Link to comment https://forums.phpfreaks.com/topic/85743-solved-refreshing-clock-but-not-page/#findComment-437713 Share on other sites More sharing options...
p2grace Posted January 13, 2008 Share Posted January 13, 2008 I use ajax on a daily basis, I'm not saying ajax wouldn't be the ideal solution. What I am saying, is if he is new to php, ajax might be a little more complicated for him, and there are hundreds of javascript date and time scripts out there he could easily implement. I wasn't answering the question in terms of stability, rather in terms of feasibility Quote Link to comment https://forums.phpfreaks.com/topic/85743-solved-refreshing-clock-but-not-page/#findComment-437752 Share on other sites More sharing options...
Hypnos Posted January 13, 2008 Share Posted January 13, 2008 That would be a javascript question. http://www.w3schools.com/js/js_obj_date.asp You can easily feed a javascript date object with the PHP date function, then use javascript to keep it incrimenting. Quote Link to comment https://forums.phpfreaks.com/topic/85743-solved-refreshing-clock-but-not-page/#findComment-437770 Share on other sites More sharing options...
twostars Posted January 13, 2008 Share Posted January 13, 2008 then use javascript to keep it incrimenting. And there lies the flaw. I've seen scripts get 'out of sync' with the real time after a little while. Quote Link to comment https://forums.phpfreaks.com/topic/85743-solved-refreshing-clock-but-not-page/#findComment-437807 Share on other sites More sharing options...
tinker Posted January 13, 2008 Share Posted January 13, 2008 how do you get php to update just part of a page on the client side? (without ajax or refresh) because a person who has knowledge in AJAX would know that PHP can refresh a certain part of the code. AJAX shouldn't scare anyone, basically in my experience it's two functions and you've got a system which links your javascript to a server and cgi. I use an amended version of this. Quote Link to comment https://forums.phpfreaks.com/topic/85743-solved-refreshing-clock-but-not-page/#findComment-437857 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.