Subtract 40 days from the 15th of March, 2013:
<?php
$date=date_create("2013-03-15");
date_sub($date,date_interval_create_from_date_string("40 days"));
echo date_format($date,"Y-m-d");
?>
Try it Yourself »
The date_sub() function subtracts some days, months, years, hours, minutes, and seconds from a date.
date_sub(
object, interval)
Parameter | Description |
---|---|
object | Required. Specifies a DateTime object returned by date_create() |
interval | Required. Specifies a DateInterval object |
Return Value: | Returns a DateTime object on success. FALSE on failure |
---|---|
PHP Version: | 5.3+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!