Created
November 3, 2014 14:13
-
-
Save dave-jay/0186c38061b1e04a50c7 to your computer and use it in GitHub Desktop.
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 | |
function _dateDiff($date1, $date2) { | |
$time = strtotime($date1); | |
$time2 = strtotime($date2); | |
$diff = $time - $time2; | |
$return = array(); | |
$days = $diff / (60 * 60 * 24 ); | |
$whole = floor($days); | |
$hours = intval(($days - $whole)*24); | |
$return['days'] = intval($days); | |
$return['hours'] = $hours; | |
return $return;; | |
} | |
_dateDiff("2014-11-05 11:00:00", "2014-11-01 13:00:00")); | |
# returns: | |
/* | |
...Array | |
( | |
[days] => 3 | |
[hours] => 23 | |
) | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment