Skip to content

Instantly share code, notes, and snippets.

@biswarupadhikari
Created September 30, 2013 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biswarupadhikari/6765687 to your computer and use it in GitHub Desktop.
Save biswarupadhikari/6765687 to your computer and use it in GitHub Desktop.
Datetime difference in Hour
<?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