date_sub

Its an alias of DateTime::sub()and subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object
Example

<?php
$date = date_create(‘2012-05-17′);
date_sub($date, date_interval_create_from_date_string(’11 days’));
echo date_format($date, ‘Y-m-d’);
?>

Output

2012-05-06


Share