DateTime::sub

PHP 5 >= 5.3.0, PHP 7, PHP 8
DateTime::sub - Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object
Manual
Code Examples

DateTime::sub( DateInterval$interval ): public DateTime

Procedural style

DateTimedate_sub DateTimeobject DateIntervalinterval

Parameters

object

Procedural style only: A DateTime object returned by date_create. The function modifies this object.

interval

A DateInterval object

Return Values

Returns the DateTime object for method chaining or false on failure.

Related Functions

Example of DateTime::sub

Show all examples for DateTime::sub

PHP Version:


Function DateTime::sub:

Date and Time Functions

Most used PHP functions