How to get time difference in minutes in PHP

How to get time difference in minutes in PHP

Asked on December 8, 2018 in PHP.
Add Comment


  • 3 Answer(s)

    The solution is, we have to subtract the last most one from the future one.

    Then we have to  divide it  by 60.

    They’re just a big number showing the number of seconds from January 1, 1970, 00:00:00 GMT, Because times are done in Unix forma

    Answered on December 8, 2018.
    Add Comment

    The easiest solution ever,

    $to_time = strtotime("2008-12-13 10:42:00");
    $from_time = strtotime("2008-12-13 10:21:00");
    echo round(abs($to_time - $from_time) / 60,2). " minute";
    
    Answered on December 8, 2018.
    Add Comment

    I think this is a cool and easy way,

    <?php
    $date1 = time();
    sleep(2000);
    $date2 = time();
    $mins = ($date2 - $date1) / 60;
    echo $mins;
    ?>
    
    Answered on December 8, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.