Skip to content

Instantly share code, notes, and snippets.

@BenjaminGuV
Created May 28, 2012 11:23
Show Gist options
  • Save BenjaminGuV/2818637 to your computer and use it in GitHub Desktop.
Save BenjaminGuV/2818637 to your computer and use it in GitHub Desktop.
procesar fecha
<?php
class Fecha
{
private $dia = array();
private $mes = array();
private $anio = array();
function __construct()
{
}
public function calcDias( $fhInicio, $fhFin, $hrInicio, $hrFin)
{
list( $this->anio['inicio'], $this->mes['inicio'], $this->dia['inicio'] ) = explode('-', $fhInicio);
list( $this->anio['fin'], $this->mes['fin'], $this->dia['fin'] ) = explode('-', $fhFin);
$timeInicial = mktime( $hrInicio, 0, 0, $this->mes['inicio'], $this->dia['inicio'], $this->anio['inicio']);
$timeFinal = mktime( $hrFin, 0, 0, $this->mes['fin'], $this->dia['fin'], $this->anio['fin']);
$totalDias = $timeFinal - $timeInicial;
$diasTotal = $totalDias / (60 * 60 * 24);
return ceil( $diasTotal );
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment