PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
how can i take two dates and times and find out the total time spent e.g.
10 april 2006 12:00:00 and 10 april 2006 14:15:15 which would give me 2:15:15 spent
10 april 2006 12:00:00 and 11 april 2006 14:15:15 which would give me 14:15:15 spent
and what is the best way to capture this information?
ttid, int, auto increment
tt_date_time_clockin, datetime
tt_date_time_clockout, datetime
tt_total_time_taken, time stamp
1, 2006-04-10 12:00:00, 2006-04-10 14:15:15, 2:15:15
2, 2006-04-10 12:00:00, 2006-04-11 14:15:15, 14:15:15
On the screen it will display: here i count the tt_total_time_taken
total time = 16 hours and 30 minutes 30 seconds
The question is how do I take the tt_date_time_clockin and tt_date_time_clockout and work out the tt_total_time_taken?
Take a look at mktime() - it converts the date into the number of seconds since 1970, allowing you to perform calculations.
date() will convert it back again.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I got part of this work but it has a problem when I input a "d1" as a date less than today...
Works properly if "d1" is todays date
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]