[PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Bruce Gilbert
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' .

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Peter Lind
On 25 May 2010 15:55, Bruce Gilbert wrote: > 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 da

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Bruce Gilbert
Thanks. I know my syntax isn't quite right, but is this close to what I need to do? echo "Completion Time:" . date('F j, Y g:i:sa', strtotime($row["login_timestamp"] - ["submit_timestamp"])/60) . ""; On Tue, May 25, 2010 at 10:01 AM, Peter Lind wrote: > On 25 May 2010 15:55, Bruce Gilbert wro

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Peter Lind
On 25 May 2010 16:14, Bruce Gilbert wrote: > Thanks. I know my syntax isn't quite right, but is this close to what > I need to do? > > echo "Completion Time:" . date('F j, Y > g:i:sa', strtotime($row["login_timestamp"] - ["submit_timestamp"])/60) > . ""; > No. Assuming that your timestamp is of t

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Bruce Gilbert
Here is what I currently have. echo "Completion Time:" . (strtotime($row['submit_timestamp']) - strtotime($row['login_timestamp']))/60 , ""; this gives me an output of 21235172.75 not sure what format that is in? I was hoping for something like 60 minutes, 30 minutes etc. Don't need the days or

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Ashley Sheridan
On Tue, 2010-05-25 at 12:46 -0400, Bruce Gilbert wrote: > Here is what I currently have. > > echo "Completion Time:" . > (strtotime($row['submit_timestamp']) - > strtotime($row['login_timestamp']))/60 , ""; > > this gives me an output of 21235172.75 > > not sure what format that is in? I was ho

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Bruce Gilbert
probably not fully understanding what I need to do. I am trying this. echo "Completion Time:". date('F j, Y g:i:sa',strtotime($row['submit_timestamp']) - strtotime($row['login_timestamp']))/60 , ""; but just returns a zero value. On Tue, May 25, 2010 at 12:55 PM, Ashley Sheridan wrote: > On

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Ashley Sheridan
On Tue, 2010-05-25 at 14:22 -0400, Bruce Gilbert wrote: > echo "Completion Time:". date('F j, Y > g:i:sa',strtotime($row['submit_timestamp']) - > strtotime($row['login_timestamp']))/60 , ""; There's a good reason for that! What you're actually doing is this: echo "Completion Time:" . date('F j,

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Bruce Gilbert
the resulting output with that code is a little weird. I get September 3, 1970 2:39:32pm I think part of the problem is my Query. When I run it in PHP MyAdmin I get a null value for login_timestamp even though there is indeed a timestamp there. The Query again is: SELECT Responses.editor_name,An

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Ashley Sheridan
On Tue, 2010-05-25 at 15:09 -0400, Bruce Gilbert wrote: > the resulting output with that code is a little weird. I get September > 3, 1970 2:39:32pm > > I think part of the problem is my Query. When I run it in PHP MyAdmin > I get a null value for login_timestamp even though there is indeed a > t

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Peter Lind
On 25 May 2010 21:09, Bruce Gilbert wrote: > the resulting output with that code is a little weird. I get September > 3, 1970 2:39:32pm > > I think part of the problem is my Query. When I run it in PHP MyAdmin > I get a null value for login_timestamp even though there is indeed a > timestamp there

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Nathan Rixham
Ashley Sheridan wrote: On Tue, 2010-05-25 at 14:22 -0400, Bruce Gilbert wrote: echo "Completion Time:". date('F j, Y g:i:sa',strtotime($row['submit_timestamp']) - strtotime($row['login_timestamp']))/60 , ""; There's a good reason for that! What you're actually doing is this: echo "Completion

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Bruce Gilbert
yea, not sure why my Query isn't returning a value though? If I don't use date(), what should I use? the SQL for the timestamps looks like this. `login_timestamp` datetime NOT NULL default '-00-00 00:00:00', `submit_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, sorry for the top-po

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Peter Lind
On 25 May 2010 21:50, Bruce Gilbert wrote: > yea, not sure why my Query isn't returning a value though? If I don't > use date(), what should I use? The output of strtotime() is an int - specifically a number of seconds. Subtract two number of seconds from each other and what do you get? Furthermo

Re: [PHP] determining time difference between two timestamp fields.

2010-05-25 Thread Bruce Gilbert
thanks again for all the help. >The output of strtotime() is an int - specifically a number of >seconds. Subtract two number of seconds from each other and what do >you get? Furthermore, divide by 60 and what do you get? > Should you want to format this, you can consider sprintf(), though, >if you