View Full Version : php calculate time differance problem

01-18-2012, 11:03 AM
hi i have this code

$sqlstr13="SELECT * FROM barcode WHERE Internal ='$preinternal' ";

$result13= mysql_query($sqlstr13);
$recordinput13= mysql_fetch_array($result13);


$today2 = date("G:i:s");

so now i`m subtracting


in hear working perfectly for the time differance less than 1 minte

but time differance above 1 min it will give zero

plz help me to solve this problemmmmmmmm

with the code

01-18-2012, 02:37 PM
This line:
$today2 = date("G:i:s");

Should be:

This line:

Change to:

time() is the UNIX timestamp right now, for your timezone.
Remember that you're using the server timezone unless you specify it otherwise.

The next issue will be the format of $recordinput13['timeB']
Can you show us how one of those values are formated in the column?

The difference between two UNIX timestamps is in seconds (that's the resolution);
So, you might get a difference of 97. That's 97 seconds. Or a negative difference is possible.