0
$curr_date = date('2015-01-28 14:23:02');
$deadtime= date('2015-01-26 15:11:00');

I am in trouble buddies? I have a difficulty in getting the minutes difference of current date to deadtime date. Can you help me with the formula? Thanks in Advance

Havelock
  • 6,913
  • 4
  • 34
  • 42
therazerme
  • 15
  • 4
  • reference can be taken from http://stackoverflow.com/questions/676824/how-to-calculate-the-difference-between-two-dates-using-php – Rajeev Ranjan Jan 28 '15 at 06:38
  • I'm voting to close this question as off-topic because it's "write my code for me" question – tomrozb Jan 28 '15 at 06:40

3 Answers3

2

Try something like this

(strtotime($curr_date) - strtotime($deadtime))/60
Vick
  • 287
  • 2
  • 8
1

You can get the full time difference through the below function

function date_getFullTimeDifference( $start, $end )
{
$uts['start']      =    strtotime( $start );
        $uts['end']        =    strtotime( $end );
        if( $uts['start']!==-1 && $uts['end']!==-1 )
        {
            if( $uts['end'] >= $uts['start'] )
            {
                $diff    =    $uts['end'] - $uts['start'];
                if( $years=intval((floor($diff/31104000))) )
                    $diff = $diff % 31104000;
                if( $months=intval((floor($diff/2592000))) )
                    $diff = $diff % 2592000;
                if( $days=intval((floor($diff/86400))) )
                    $diff = $diff % 86400;
                if( $hours=intval((floor($diff/3600))) )
                    $diff = $diff % 3600;
                if( $minutes=intval((floor($diff/60))) )
                    $diff = $diff % 60;
                $diff    =    intval( $diff );
                return( array('years'=>$years,'months'=>$months,'days'=>$days, 'hours'=>$hours, 'minutes'=>$minutes, 'seconds'=>$diff) );
            }
            else
            {
                echo "Ending date/time is earlier than the start date/time";
            }
        }
        else
        {
            echo "Invalid date/time data detected";
        }
}
Veerendra
  • 2,562
  • 2
  • 22
  • 39
0

try this,first set default_timezone

date_default_timezone_set("Iran");
$timezone = date_default_timezone_get();
$waitTime=diffTime( $deadtime,$curr_date);
ashkufaraz
  • 5,179
  • 6
  • 51
  • 82