determining time difference between two timestamp fields.
| From: | Bruce Gilbert | Date: | Tue, 25 May 2010 13:55:43 +0000 |
| Subject: | determining time difference between two timestamp fields. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-305503@lists.php.net to get a copy of this message | ||
Here is the situation. I have a form which sets a timestamp when a
user logs in using UPDATE in SQL. The field is called
'login_timestamp' and is in a table called 'Candidates'. I have
another timestamp which is set when a user submits the form data into
the DB and it is called 'submit_timestamp' . What I want to do is
determine the amount of time the user takes to complete the form by
subtracting the 'login_timestamp' time form the 'submit_timestamp'
time. I am using SQL to extract the data here.
$sql = "SELECT Responses.name,Answers,submit_timestamp,login_timestamp
FROM Responses LEFT JOIN Candidates USING (user_id)";
and then to display the timestamp in readable form.
echo "<tr><th>Completion Time:</th></tr><tr><td>" .
date('F j, Y
g:i:sa', strtotime($row["login_timestamp"])) . "</td></tr>";
so I need to know how to subtract from two timestamp fields, two
different tables and come up with the difference in minutes.
thanks.
--
::Bruce::