Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
please help me as soon as possible because i am new in this field
how can implement a stop watch in a php site for displaying the total time consume by a technician to resolve the problem
Posted
Updated 15-Jun-12 1:24am
v2

You can use this javascript stopwatch.

JavaScript Stopwatch[^]

You just need to pass the value from clientside to serverside once you are stopping the watch so that it can be stored on server(if you have to save it in DB)


[EDIT]:- (based on your comments)

Here is a little algorithm:

1. When you have to start the watch get the server time and keep it in session.
2. use javascript to show this time on page.
3. when user goes to another page read the start time again from session and display time accordingly.
4. when user hit stop, take the server time again, get the timespan using session value and store in DB.

P.S. dont know PHP else could have given you the code too.
 
Share this answer
 
v3
Comments
ambujmalviya 15-Jun-12 7:38am    
i tried use this javascript stopwatch. but it pause when i move the other page of the site and it automatically start when i come on the page again.what is the reason..?
Rahul Rajat Singh 15-Jun-12 7:42am    
check the updated solution. i added a little algo there.
ambujmalviya 15-Jun-12 7:45am    
thanks for your help but i am still unable to do this.
Rahul Rajat Singh 15-Jun-12 7:47am    
Have you tried the algorithm, i suggested. I think, it should work.
Note: Posting another solution just avoid clutter in original one:

So i did some search and it seems this page shows how to show server time on page using javascript:

http://www.coursesweb.net/javascript/javascript-code-php[^]

Now you can use this code and modify it with as for my algo or here is second also.

0. use this above code to show server time on client.
1. when timer starts, save this time in DB, on server.
2. when it stops, send this time to server.
3. now calculate the timespan based on the old value and new value and save it.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900