close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Calculate Difference in Time with PHP

Thread began 3/12/2010 10:57 am by tom92909 | Last modified 3/15/2010 1:47 pm by tom92909 | 2558 views | 2 replies

tom92909Beta Tester

Calculate Difference in Time with PHP

Howdy folks! :)

I've been working on a new project that calculates hours worked. I need to take up to three 24hr clock IN and clock OUT entries stored in MySQL and come up with a calculated sum difference in time.

I've seen lots of examples from folks via Google searches, but I'm stuck. I can't seem to get the the calculations right.

I am storing up to a possible 3 entries per/work day. Below is my weak attempt to get started...

php:
$query = "SELECT * FROM emphours

        WHERE `Date` BETWEEN '".$_POST['Start']."' and '".$_POST['End']."'";

    $time1=$row["Out1"]-$row["In1"]; 
    $ext1 = "$time1:";

    $time2=$row["Out2"]-$row["In2"]; 
    $ext2 = "$time2:";

    $time3=$row["Out3"]-$row["In3"]; 
    $ext3 = "$time3:";

    $ExtTot = $ext1 + $ext2 + $ext2;




I found a web tool that is an outstanding example of what I'm trying to accomplish, except I need to make some modifications to suit my exact requirements... I'm attempting to contact the author/website owner to gain some insight.

timesheet.php

The scripting this site has is right on target.

Any tips, pointers, suggestions would be greatly appreciated.


Tom

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...