Hi How to get the timedifference between two datetime values one im fetching frm database and other im comparing from input i have both dates in form yyyy-mm-dd hr:min:sec i want to get timediff between two values in above format please help...
use strtotime to convert two dates into seconds $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 Code (markup): or you can use the mysql TIMEDIFF $query = select TIMEDIFF(field_name, '$input_date') from tbl_name where condition Code (markup):
Hello, u can use like this $date1 = mktime($hr,$min,$sec,$fromMonth,$fromDay,$fromYear); $date2 = mktime($hr1,$min1,$sec1,$ToMonth,$ToDay,$ToYear); $dateDiff = $date2 - $date1; $timeDifference= floor($dateDiff/(60*60*24)); Regards Stylesofts Developing Team
I do it like this: <?php $sttime = microtime(true); //start timer for time it takes to load the page - put as first line on page ... $timediff = round((microtime(true) - $sttime), 5); //ends time - put as close to the end of the page as possible. ?> PHP: hth