Your Open Source

 
Related Posts
QA  >>  Web Development  >>  PHP

time difference callculation

I want know how to calculate the difference between the times,
For example, time_1 is "08:30:12" and second time is "08:40:50" and I want to know the time "08:34:01"is between the two times or not, please give me your suggestion.

  • hits 112
  • datetime Sep 01 09 01:34:44
  • author Tech
  • rating

Rating : 12345
Tags :- PHP

Answers

sekar
Sep 01 09 01:51:27
Please check the following code, I hope it will helpful for you.


<?php
$from = "08:30:12";
$to = "08:41:01";
$check = "08:35:01";
echo  isBetween($from,$to,$check);

function isBetween($from,$to, $check){
  if((changeTimeFormat($from) < changeTimeFormat($check))  && (changeTimeFormat($to) > changeTimeFormat($check))   ){
      return 1;
  }else{
    return 0; 
  }
}
function changeTimeFormat($time){
    return str_replace(":","",$time) + 0;
   
}
?>

Your Name:
Your Answers :
<> is a code tag
Preview
Enter the verification code: