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

Example #1 Further DateTime::sub examples

Result: 2000-01-19 13:59:30 1992-08-15 19:56:58
PHP Version:

Example #2 Beware when subtracting months

Result: 2001-03-30 2001-03-02
PHP Version:

Example #3 DateTime::sub example

Result: 2000-01-10
PHP Version:


Function DateTime::sub:

Date and Time Functions

Most used PHP functions