Link to home
Start Free TrialLog in
Avatar of RupertA
RupertAFlag for United Kingdom of Great Britain and Northern Ireland

asked on

calculating elapsed time on webpage

Hi, I would like to be able to calculate the elapsed time from my webpage (page.htm) opening to the clicking of a submit button on page.htm which submits the time variable to my php file. The time would be in the format 00:00:00, where it is hours:minutes:seconds.

Could somebody give me the code for this? I would imagine I will need to put something in the head section and some code on the submit button.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of brad2575
brad2575
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RupertA

ASKER

Thanks for your reply brad, I actually ended up using some code on another thread shown below. However I wil hand out points as you did help and am sure yours would be a workable solution. But this is what I came up with

as a rough idea - the big number is milliseconds

<script type="text/javascript">
 
var d = new Date();
d.setTime(7395000);
document.write(d+"<br/>");
 
document.write(d.getHours()+"hours<br/>");
document.write(d.getMinutes()+"minutes<br/>");
document.write(d.getSeconds()+"second<br/>");
 
document.write(d.getHours() + ":" +d.getMinutes()+":" +d.getSeconds() +"<br/>");

</script>