Following code will show you how to get time difference in second from a two datetime values. Remember datetime should be in this format: yyyy-mm-dd hr:min:sec
$dbdate_seconds = strtotime($dbdate);
$inputdate_seconds = strtotime($inputdate);
$time_diff = $dbdate_seconds - $inputdate_seconds;
//you will get the time difference in seconds, divide by 60 to make it minutes
or you can use the mysql TIMEDIFF
$query = select TIMEDIFF(field_name, '$input_date') from tbl_name where condition
No comments:
Post a Comment