Portal Home > Knowledgebase > Articles Database > PHP Help


PHP Help




Posted by Danny159, 06-26-2008, 12:38 PM
Hey I want to design a script that will show a client how much time i spend on their project.. So on my admin panel I will click onto the client and view profile then i go to time and there will be a clock... starting at 00.00 and when i press a start button it starts counting up (eg from 00.00 to 00.01 then 01.00 as an hour) then when i press stop it stores it in the database so next time i go on it starts at the time i stopped it... Can this be done? I know it can but can someone help me with this bit of code? Danny

Posted by stanosf, 06-26-2008, 03:38 PM
i would just insert a new row to the db (with a timestamp field) then on the second click insert another table work_periods int entryID timestamp eventTime int eventType where eventType encoded if this was a "start work" or "stop work" Much more elegant solutions exist but this should do what you want in a quick fashion.

Posted by Danny159, 06-26-2008, 04:05 PM
Thanks alot, Could you possably post a bit of code to explain more? Danny

Posted by RN-Chris, 06-26-2008, 04:12 PM
Well maybe tell us what you have so far so we know what area your having the problem with. Just posting general code is kinda abstract ya know?

Posted by Steve_Arm, 06-26-2008, 05:09 PM
Wouldn't it be better to find a project management software and skip the hassle?

Posted by Adam-AEC, 06-27-2008, 02:43 PM
What happens if your system freezes and you need to restart? The timer is lost. I'm not sure if I would re-invent the wheel here, unless you want to incorporate some AJAX to update the database with the running timer status. You could look into incorporating the Slimtimer API into your application.

Posted by thehotweb, 06-28-2008, 01:07 AM
The easy fix for this would be to add the start time to the database when start is clicked and then add the end time once end if clicked.

Posted by greg2007, 06-28-2008, 02:58 PM
PHP loads all the script for a given page and then ends, either by end of script or error. As such PHP probably isn't your best solution for this as you would have to load a page/script in order to count. The best suggestion so far is take a timestamp on a click of a button (that will be start) then take a timestamp on next click (or another button) that would be stop. The difference between the two timestamps would be used to tell you the total time spent. But, being practical, don't you have a clock on your wrist/desk/wall/PC? I'm not being funny, but for the time taken to make this code, have database fields or even a table just for this it all seems a bit over the top You have to work out how you want it all to work, and what you want it to store. The basic would be You have two DB table fields, one for start time storage and one for total time spent. You click start and current timestamp is stored. You click stop and it gets stored timestamp, works out difference and stores that timestamp (which is the total time you spent) in the TOTAL field in the DB. This would also rule out any problems if your pc crashes/internet goes down etc as all you do is note the time you would have clicked "stop" on your timer script and when you get back online (or whatever) manually work out the difference from stored time to the one you noted. (this is of course unlikely to happen anyway) But it proves no more to a client how long you spent on their project then sending them an email with your total time spent. If you just want to keep track of time you spent on projects then a local (on your pc) spreadsheet would be better. You can also store when you have breaks and for how long etc You could do all this easily with PHP too, but it's a lot of work if it's simply to store data that wont be manupulated by users/members/clients or calculations Even a pen and paper would do. Last edited by greg2007; 06-28-2008 at 03:02 PM.

Posted by Burhan, 06-29-2008, 05:08 PM
Basecamp. Save yourself the headache.

Posted by johringer, 06-29-2008, 05:13 PM
Great software, I agree. Also note, the link is actually: http://www.basecamphq.com.

Posted by orbitz, 06-30-2008, 11:36 AM
Simple approach -- Get a clock which prices less than $4.00 and start timing yourself when you work. When done, just put the time you spent to database Last edited by orbitz; 06-30-2008 at 11:41 AM.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
WHMAP problem (Views: 579)
does thsi sound good? (Views: 571)