How to Subtract Months to Date in PHP

In this tutorial, I will show you how to subtract months to date in PHP. Many projects need this type of specialty so, let’s start in code so you easily understand how to subtract months.

The following source code will subtract 2 months to current date.

<?php
    echo date('Y-m-d', strtotime(' - 2 month')); 
?>

The following source code will subtract 2 months to date.

<?php
    $date = "2018-05-19";
    echo date('Y-m-d', strtotime($date. ' - 2 month'));
?>

And if you like this tutorials please share it with your friends via Email or Social Media.

Leave a Reply

Your email address will not be published. Required fields are marked *