Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php calculate hours and minutes between two times

date_default_timezone_set("Africa/Johannesburg");
    $now = new DateTime();
    $future_date = new DateTime('2020-10-21 00:00:00');
    
    $interval = $future_date->diff($now);
    
    echo ($interval->format("%a") * 24) + $interval->format("%h"). " hours". $interval->format(" %i minutes ");
    print_r($now->format('Y-m-d H:i:s'));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #calculate #hours #minutes #times
ADD COMMENT
Topic
Name
3+8 =