Created
September 30, 2013 15:39
-
-
Save biswarupadhikari/6765687 to your computer and use it in GitHub Desktop.
Datetime difference in Hour
This file contains hidden or 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 getTimeDifference($start_time,$stop_time){ $start_time=strtotime($start_time); $stop_time=strtotime($stop_time); $seconds=$stop_time - $start_time; if($seconds > 3600 ){ $hours=floor($seconds / 3600); $seconds=$seconds % 3600; }else{ $hours='00'; } if($seconds > 60 ){ $minutes=floor($seconds / 60); $seconds=$seconds % 60; }else{ $minutes='00'; } return $hours.':'.$minutes.':'.$seconds; } echo getTimeDifference('2013-05-11 13:24:48','2013-05-12 13:59:49'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment