PHP date_sub() Function

PHP date_sub Function


Definition :

In php  date_sub()  Function is inbuilt function.The date_sub() function is used to subtracts some days, months, years, hours, minutes, and seconds from a date. The function returns a DateTime object on success otherwise,it returns FALSE on failure.

Syntax

   date_sub(object, interval)

Parameter
Parameter Description
object Required. Specifies a DateTime object returned by date_create()
interval Required. Specifies a DateInterval object

Given below example Subtract 35days from the 16th of April, 2016:

Output : 2016-03-12