Created
March 2, 2018 16:24
-
-
Save FabianoFaria/6a54edd4998e9d173b8fdcfdab3a32b2 to your computer and use it in GitHub Desktop.
Diferença entre duas datas para versões antigas de PHP
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
function GetDateDiffFromNow($date1, $date2) | |
{ | |
$unixOriginalDate = strtotime($date1); | |
$unixNowDate = strtotime($date2); | |
$difference = $unixNowDate - $unixOriginalDate ; | |
$days = (int)($difference / 86400); | |
$hours = (int)($difference / 3600); | |
$minutes = (int)($difference / 60); | |
$seconds = $difference; | |
$atrasado = false; | |
if($days < 0){ | |
$atrasado = true; | |
} | |
$tempoDecorrido = $arrayName = array('dias' => $days, | |
'negativo' => $atrasado); | |
return $tempoDecorrido; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment