Current location: Hot Scripts Forums » Programming Languages » PHP » MySQL Time Tracker


MySQL Time Tracker

Reply
  #1 (permalink)  
Old 09-27-04, 07:20 AM
Ramses99 Ramses99 is offline
Newbie Coder
 
Join Date: Sep 2004
Location: NS. Canada
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
MySQL Time Tracker

Hey everyone.

This is probabily a simple issue, with a some-what simple solution...
I'm trying to put together a MySQL table(s) where I can insert the times I punch in and out of work and be able to calculate total time 'working'.

I'm not sure exactly how to go about doing this. Any ideas or thoughts would be very much appreciated.

Thanks.
Reply With Quote
  #2 (permalink)  
Old 09-27-04, 09:00 AM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
ok ill brain storm a lil bit

lets do military time
PHP Code:

$inhour date(H)

$inmin date(i)

$outhour date(H)
$outmin date(i)

if (
$inhour $outhour){$hours=$inhour-$outhour;}else{$hours=$outhour-$inhour;}
if (
$inmin $outmin){$mins=$inmin-$outmin;}else{$mins=$outmin-$inmin;}
$time $hours.':'.$mins

echo "You have worked".$time." today."
than just add the MySQL element /shrug ... that how i would base it.. problems i see are if you punch in at 23:50 and punch out at 8:50 =/
Reply With Quote
  #3 (permalink)  
Old 09-27-04, 09:44 AM
Ramses99 Ramses99 is offline
Newbie Coder
 
Join Date: Sep 2004
Location: NS. Canada
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
I like that.... that would work quite well.... Would have to revamp it a bit for the lunch break.. but over-all I think it would work. Actually doing it this way would make things much easier from the MySQL end of things... just store the total work times for each week/month or whatever. Yes... that will work...

Quote:
problems i see are if you punch in at 23:50 and punch out at 8:50 =/
How did you know???? Ya, I work nights so that would be an issue. Easily solved by adding another area with which I could enter the amount of min that are not covered by the initial time-in.

THANKS
Reply With Quote
  #4 (permalink)  
Old 09-27-04, 11:13 AM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
I just thought that was a simple way of doing it im not sure if it will work ( i did not run the code) but it should work with some tweaking

i'm glad i could contribute
Reply With Quote
  #5 (permalink)  
Old 09-27-04, 03:07 PM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
why dont just store unix timestamp with time() and calculate from there?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
inserting and retrieving date and time from mysql database stealth04 PHP 5 07-29-04 11:19 AM
MYSQL time out error rsuresh PHP 0 07-05-04 07:15 AM
Upload image & text to MYSQL --> AT THE SAME TIME? charliedhq PHP 1 02-20-04 02:57 PM
MySQL loading time CHIngs PHP 1 08-01-03 05:42 PM


All times are GMT -5. The time now is 04:33 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.