Your Location is: Home > Php

PHP How to calculate the hour and minutes between two dates?

From: Romania View: 1161 Walrus 

Question

This php script gives differences days and hour between two dates. But i can't calculate remaining minutes

  <?php
    $datestr="2011-09-23 19:10:18";
    $date=strtotime($datestr);
    
    $diff=$date-time();//time returns current time in seconds
    $days=floor($diff/(60*60*24));//seconds/minute*minutes/hour*hours/day)
    $hours=round(($diff-$days*60*60*24)/(60*60));
    
    echo "$days days $hours hours remain<br />";
    ?>

Best answer