Ashley Sheridan wrote:
On Tue, 2010-05-25 at 14:22 -0400, Bruce Gilbert wrote:
echo "<tr><th>Completion Time:</th></tr><tr><td>". date('F j, Y
g:i:sa',strtotime($row['submit_timestamp']) -
strtotime($row['login_timestamp']))/60 , "</td></tr>";
There's a good reason for that! What you're actually doing is this:
echo "<tr><th>Completion Time:</th></tr><tr><td>" .
date('F j, Y g:i:sa',
strtotime($row['submit_timestamp']) -
strtotime($row['login_timestamp'])
)
/ 60
, "</td></tr>";
You're trying to divide a string by 60, because date() returns a string.
Put that division inside the brackets for date() rather than outside.
It might help to break up that whole line of output into several parts.
Put the date into a variable and then just output the HTML line:
$date = date('F j, Y g:i:sa', (strtotime($row['submit_timestamp']) -
strtotime($row['login_timestamp']))/60);
echo "<tr><th>Completion Time:</th></tr><tr><td>$date</td></tr>";
Ash is right :)
If I may add a little observation, this (and many things like it) may be
easier to approach and debug if you handle just one operation at a time;
break it down in to little chunks.
For instance:
$submit_time = strtotime($row['submit_timestamp']);
$login_time = strtotime($row['login_timestamp']);
$completion_time = $submit_time - $login_time;
$completion_time /= 60;
$formatted_completion_time = date('F j, Y g:i:sa', $completion_time );
echo "<tr><th>Completion Time:</th></tr><tr><td>";
echo $formatted_completion_time;
echo "</td></tr>";
Sure it's verbose, but it's also so much easier to debug, and you can
always tidy / crunch it up afterwards.
Best,
Nathan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php