Skip to content

Instantly share code, notes, and snippets.

@csalgueiro
Created December 28, 2016 09:52
Show Gist options
  • Save csalgueiro/1f5cfc9e45f51d349cdfc90527fff44d to your computer and use it in GitHub Desktop.
Save csalgueiro/1f5cfc9e45f51d349cdfc90527fff44d to your computer and use it in GitHub Desktop.
diferencia de horas php con strtotime
$hora_ini = "08:15";
$hora_fin = "09:30";
$fecha = date("Y-m-d");
$ts_fin = strtotime($fecha." ".$hora_fin);
$ts_ini = strtotime($fecha." ".$hora_ini);
echo "TS_INI: ".$ts_ini."<br>";
echo "TS_FIN: ".$ts_fin."<br>";
echo "DIFF: ".($ts_fin-$ts_ini)/3600;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment