How to Subtract Years to Date in PHP

In this tutorial i will show you how to subtract years to date in PHP. Many project need this type speciality so, let’s start in code so you are easily understand how to subtract years. You may also like How to add one year in current date using php and How to Subtract one Year in Current date using PHP.

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

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

The following source code will subtract 2 years to date.

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

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 *