Add rows and calculate seconds in every row

action.php (784 Bytes)
database.php (826 Bytes)
add_row.php (1.2 KB)
delete.php (1.2 KB)
index.php (3.0 KB)
time_calculation.php (1.2 KB)
time_convert.php (764 Bytes)
problem.txt (41 Bytes)

What’s the question here? If you’re asking for PHP code to calculate the duration in seconds between the start and end times and display it in the box, post the relevant section of code in the forum, not links to your entire codebase so we can try to find it.

From the look of your image, the problem you might be having is that the “Start Time” entries are in the format of "hh::mm:ss", the spurious : between the hours and minutes is making them invalid and probably evaluate to 00:00:00. But I’m only guessing what the problem is.

Hi droopsnoot,

I want to subtract from end_time to start_time then the result shown in seconds. It will be running in more mows.

and what do you say to the rest of @droopsnoot 's posting?

action.php (784 Bytes)
action2.php (789 Bytes)
add_row.php (1.2 KB)
time_calculation.php (1.2 KB)
database.php (826 Bytes)
index.php (3.1 KB)
delete.php (1.2 KB)
single_row.php (2.9 KB)
time_convert.php (808 Bytes)

Please isolate the section of your code that is dealing with calculating and displaying the duration, and post it directly here so someone can see what’s wrong. If this is running at the browser, is it even PHP code that is failing? Sorry, but I don’t have spare time to download all your code and try to figure out which part of it actually deals with the problem you are having. Maybe later on, the rest of the code might be needed but, for now, please just post that part that deals with the calculation.

Not that this is the only problem, there might be others, but the code in time_calculation.php is very old and needs to be brought up to date (unless you are unfortunate enough to be running a dead version of PHP) i.e.

function get_time_difference( $start, $end )
{
  $uts['start']      =    strtotime( $start );
  $uts['end']        =    strtotime( $end );
  if( $uts['start']!==-1 && $uts['end']!==-1 ) 

http://php.net/manual/en/function.strtotime.php

Return Values
Returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0, this function would return -1 on failure.

While you’re at it, “start” and “end” could be variables without being array keys unless “uts” is global.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.