Jump to content

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);
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.