Skip to content

Instantly share code, notes, and snippets.

@caionorder
Created August 6, 2020 22:11
Show Gist options
  • Save caionorder/120adfde1899b24529570b1414aee30a to your computer and use it in GitHub Desktop.
Save caionorder/120adfde1899b24529570b1414aee30a to your computer and use it in GitHub Desktop.
<?php
function somar_horas($inicio,$fim){
$final = new DateTime();
$inicio = DateTime::createFromFormat('H:i:s', $inicio);
$fim = DateTime::createFromFormat('H:i:s', $fim);
$val01 = $inicio->getTimestamp();
$val02 = $fim->getTimestamp();
$final_hora = strtotime($val01)+strtotime($val02);
pr(date('H:i:s',($final_hora)));
die();
$final->setTimestamp($final_hora);
echo($final->format('%H:%I:%S'));
die();
// return $intervalo->format('%H:%I:%S');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment