i am doing a time management project for school to make keeping track of school and projects and the time spent on them easier..
but what i have been unable to find, is how to add time up. Can somebody please help me?
i am doing a time management project for school to make keeping track of school and projects and the time spent on them easier..
but what i have been unable to find, is how to add time up. Can somebody please help me?
What do you mean?
This may not be what you're looking for, but you can store time (relative to the unix epoch, in seconds) using the time() function and then compare it later. You can use mktime() to make things user-readable
http://www.php.net/manual/en/function.mktime.php
I'm sorry i worded it in a way that made it hard to describe it.
The user of the application is going to input a time they started and a time they stopped, for recording how long they spent on it. I need to make MySQL find out how long they spent on it.
Okay, just have them input it in a format, store it as time - use strtotime(), then calculate the difference, and divide by 60 twice to get the hours spent on it.
it looks like that only works with comparing it to the current time.. the user will have to input both when they started and when they stopped.
Just store both...
this is what i found works
note: start: 14:42:00 and end: 16:43:00Code:mysql> select time_to_sec(end) from timetest; 60780 mysql> select time_to_sec(start) from timetest; 52920 mysql> select 60780-52920; 7860 mysql> select sec_to_time('7860'); 02:11:00
[quote author=Dusk_Knight link=board=9;threadid=9392;start=0#msg85149 date=1088116825]
this is what i found works
note: start: 14:42:00 and end: 16:43:00Code:mysql> select time_to_sec(end) from timetest; 60780 mysql> select time_to_sec(start) from timetest; 52920 mysql> select 60780-52920; 7860 mysql> select sec_to_time('7860'); 02:11:00
[/quote]
That way you can have multiple rows and it adds all the rows.Code:select sec_to_time(sum((time_to_sec(end) - time_to_sec(start)))) from timetest;
Thanks gorn, that will make everything a whole lot easier.![]()
I created a time management weblication for work. I have the code @ home. Send me a PM with your email addy and I'll glady send it to you this weekend if you want to deconstruct it.
Bookmarks