Subtract Minutes from DateTime in PHP [ Solution ]

    By: Manu
    2 years ago

    In this tutorial i will give you example of php subtract minutes from datetime. Subtract minutes from current time using php. I will use how to subtract minutes from time in php. This article shows in detail, how to subtract minutes from current time in php.

    So here is a very simple example how to sub minutes to date and time in PHP.


    Subtracting from given time


    <?php
    
        $date = "2021-12-05 5:10:05";
    
        $newDate = date('Y-m-d H:i:s', strtotime($date. ' -10 minutes'));
    
        echo $newDate;
    
    ?>
    

    Output

    2021-12-015 5:00:05
    


    Subtracting from current time


    <?php
    
        $newDate = date('Y-m-d H:i:s', strtotime(' -10 minutes'));
    
        echo $newDate;
    
    ?>
    

    output

    2021-10-01 06:39:33