Search code examples
phpdatedate-format

How do I remove 3 months from a date?


Assume the date is:

$date = "2011-08-28";

It need to calculate 3 months previous to $date - how can that be done?


Solution

  • $new_timestamp = strtotime('-3 months', strtotime($date));
    

    You can then use the new timestamp with the php date() function to display the new date how you wish, for example:

    echo date("Y-m-d",$new_timestamp);