PHP ManualDateTime::subdate_sub(PHP 5 >= 5.3.0) DateTime::sub -- date_sub — Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object DescriptionObject oriented style Procedural style Subtracts the specified DateInterval object from the specified DateTime object. Parameters
Return Values
Returns the DateTime object for method chaining or ExamplesExample #1 DateTime::sub() example Object oriented style
<?php Procedural style
<?php The above examples will output: 2000-01-10 Example #2 Further DateTime::sub() examples
<?php The above example will output: 2000-01-19 13:59:30 1992-08-15 19:56:58 Example #3 Beware when subtracting months
<?php The above example will output: 2001-03-30 2001-03-02 NotesDateTime::modify() is an alternative when using PHP 5.2. See Also
![]() |
PHP-Index
New Tutorial entries
|