Created
November 3, 2014 13:35
-
-
Save dave-jay/5e41b289ef239527b463 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) { | |
$time1 = new DateTime($date1); | |
$time2 = new DateTime($date2); | |
$interval = $time1->diff($time2); | |
$return = array(); | |
$return['days'] = $interval->days; | |
$return['hours'] = $interval->h; | |
$return['interval'] = $interval->invert == "-1" ? "negative" : "positive"; | |
return $return; | |
} | |
$diff = _dateDiff("2014-11-02 11:00:00","2014-11-01 13:00:00")); | |
# if first date is bigger than interval = positive | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment