Created
May 28, 2012 11:23
-
-
Save BenjaminGuV/2818637 to your computer and use it in GitHub Desktop.
procesar fecha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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