Jump to content

check how many times some houer pass between 2 diff dates


arikflorida

Recommended Posts

<?php

function find_hours($date1, $date2)
{
return floor(abs(strtotime($date1) - strtotime($date2)) / (60*60));
}

echo find_hours("March 20 2006 22:00", "March 21 2006 19:00")."<br>"; //output- 21
echo find_hours("March 20 2006 20:00", "21.2.2005 13:37")."<br>"; //output- 9414
echo find_hours("2.12.2006 3PM", "2/5/07 19:15"); //output- 1564

?>

 

 

Orio.

try

<?php
function no_of_times ($srch,$start,$end) {
$start =strtotime($start);
$nstart = strtotime(date('Y-m-d ',$start ).$srch);
$out = ($start <= $nstart) ? 1 : 0;
$out += floor( (strtotime($end) - $nstart) / 86400);
return  $out;
}
$srch ='22:00:00';
$start = '2/04/07 22:00:00';
$end = '2/05/07 22:00:00';
echo no_of_times($srch, $start, $end);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.