1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
$heure1 = "09:00:00";
$heure2 = "17:10:00";
//Extractions des différents paramètres
list($h1, $m1, $sec1) = explode(':', $heure1);
list($h2, $m2, $sec2) = explode(':', $heure2);
//Calcul des timestamps
$timestamp1 = mktime ($h1, $m1, $sec1, 7, 9, 2006);
$timestamp2 = mktime ($h2, $m2, $sec2, 7, 9, 2006);
$timestamp = abs($timestamp2 - $timestamp1);
$diff_heure = floor(timestamp/3600); //Calcul des heures écoulées/restantes
$timestamp = $timestamp - ($diff_heure*3600);
$diff_min = $timestamp/60; //Calcul des minutes écoulées/restantes
echo $diff_heure."h".$diff_min."min"; // Affiche 0h50min |
Partager