Subtract 40 days from March 15, 2013:
<?php$date=date_create("2013-03-15");date_sub($date,date_interval_create_from_date_string("40 days"));echo date_format($date,"Ymd");?>The date_sub() function subtracts the day, month, year, hours, minutes, and seconds from a specified date.
date_sub( object,interval);
parameter | describe |
---|---|
object | Required. Specifies a DateTime object returned by date_create(). |
interval | Required. Specifies a DateInterval object. |
Return value: | Returns a DateTime object if successful, or FALSE if failed. |
---|---|
PHP version: | 5.3+ |