Я traying сделать математическую операцию с PHP У меня есть 2 переменные,Математические операции РНР Со временем
$a2 = $info["Hora_final"]; //END TIME Example-> 15:30:00
$a1 = $info["Hora_inicial"];//FIRST TIME Example-> 10:00:20
But i want this operation (-) minus.
$res = $a2 - $a1 ;
echo $res;
//output 5,30 Hours difference for example.
я пытаюсь с помощью этой функции, но нет, как я хочу.
$a2 = $info["Hora_final"];
$a1 = $info["Hora_inicial"];
$h2h = date('H', strtotime($a2));
$h2m = date('i', strtotime($a2));
$h2s = date('s', strtotime($a2));
$hora2 =$h2h." hour ". $h2m ." min ".$h2s ." second";
$horas_sumadas= $a1." - ". $hora2;
$text=date('H:i:s', strtotime($horas_sumadas)) ;
Спасибо вам помочь;)
Lo mejor es usar [DateTime()] (http://www.php.net/manual/es/datetime.construct.php) и [DateTime :: diff()] (http://www.php.net/manual /es/datetime.diff.php) en el manual puedes encontrar los ejemplos tanto процедурный como orientado a objetos, 'DateTime :: diff()' te devuelve la diferenca entre dos fechas en el formato que le especifiques [Формат] (http://www.php.net/manual/es/ dateinterval.format.php) –