anyone know whats the problem/reason with this codes?

1. calculation with fix time
$deff = strtotime("20:00:00")-strtotime("19:00:00");
echo date('h:i', $deff );

OUTPUT = 01:00

//above was correct

2.output should be in munite, but the output is 12:50 what's wrong with this code?

$deff = strtotime("20:00:00")-strtotime("19:10:00");
echo date('h:i', $deff );

OUTPUT = 12:50
INSTEAD OF = 00:50

anyone help would greatly appreciated..

Strange... I have just tried your second example and it is giving me 00:50.

$difference = strtotime('20:00:00') - strtotime('19:10:00');
echo date('H:i', $difference);

Have you tried adding a full date before the time to see if it makes any difference?

$difference = strtotime('2012-01-01 20:00:00') - strtotime('2012-01-01 19:10:00');
echo date('H:i', $difference);

String to time converts the string into a unix timestamp, which as I expect you know is the number of seconds since 01/01/1970. As you're only providing a time, it could be a bug with the version of PHP you're using.

I am running PHP 5.3.8. What are you using?

Neither of these are the correct approach. strtotime turns the date into an integer. You then subtract one integer from the other which gives you a difference. You are then trying to turn that difference into a date (which will result in a date close to the epoch depending in the size of the difference).

You should be using DateTime::diff - see There are worked examples there.

commented: good +15