Código PHP:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Problema</title>
</head>
<body>
<?php
include ("../Conexion/conexion.php");
if ($_POST)
{
$ficha=$_POST["nf"];
$emple=$_POST["em"];
$hi=$_POST["he"];
$hs=$_POST["hs"];
$hi2=$_POST["he2"];
$hs2=$_POST["hs2"];
}
function restaHoras($horaIni, $horaFin)
{
return (date("H:i:s", strtotime("00:00:00") + strtotime($horaFin) - strtotime($horaIni) ));
}
$total=restaHoras("$hi","$hs");
echo "<br>";
function restaHoras2($horaIni2, $horaFin2)
{
return (date("H:i:s", strtotime("00:00:00") + strtotime($horaFin2) - strtotime($horaIni2) ));
}
$total2=restaHoras2("hi2","$hs2");
echo "<br>";
/*
function sumarHoras ($valor1/*$valor2*//*)
/*
{
return (date("H:i:s", strtotime("$total") /*- strtotime($valor2)*/ /*+ strtotime($valor1) ));*/
/*}*/
/*echo $suma=sumarHoras("$total2");*/
echo date('H:s:i', strtotime('$total+ $total2'));
//resultado: 17:00:00
$sql="insert into horas2 (Numero_Ficha,Empleado,entrada,salida,Entrada2,Salida2,total) values ('$ficha','$emple','$hi','$hs','$hi2','$hs2','$suma');";
$datos=mysqli_query($conexion,$sql);
?>
<form action="" method="post">
<table align="center" border="2">
<tr>
<td align="center">Calculo</td>
</tr>
<tr>
<td>Número de ficha <input type="text" name="nf"></td>
</tr>
<tr>
<td>Empleado<input type="text" name="em"></td>
</tr>
<tr>
<td>Hora de entrada <input type="text" name="he"></td>
</tr>
<tr>
<td>Hora salida <input type="text" name="hs"></td>
</tr>
<tr>
<td>Hora de entrada #2<input type="text" name="he2"></td>
</tr>
<tr>
<td>Hora salida #2<input type="text" name="hs2"></td>
</tr>
<tr>
<td align="center"><input type="submit" value="Calcular"</td>
</tr>
</table>
</form>
</body>
</html>