By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,350 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,350 IT Pros & Developers. It's quick & easy.

show time spent on page

sanjay123456
100+
P: 125
i would like to show a clock on the page that would be calll again and again its show a clock and should be show total elapsed time how can i do it

[PHP]
<?php
$t=time();
echo($t . "<br />");
?>
[/PHP]

i found only this ?
Feb 17 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 534
I guess what you need is to have a clock on your page which would keep continuously updating the time.

If this is the case you may need to look at using Javascript + dynamic html.
(PHP is a server side code, so once page is rendered there's not much you can do)

Look at the Javascript setTimeout() function.
Using it, you can call your own function every N seconds. Your function may do something like this:
Expand|Select|Wrap|Line Numbers
  1. document.myForm.mySpan.innerHTML = <current_time>;
  2.  
For getting current date/time look at the Javascript Date object and its functions.
If you need more help with this you better off posting your question to the Javascript Forum.
Feb 17 '07 #2

Expert 100+
P: 534
Look at the Javascript setTimeout() function.
Sorry, in this case setInterval() would serve you better, it won't require a reset.
Feb 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.