|
DateTime::modifydate_modifyAlters the timestamp DescriptionObject-oriented style public DateTimefalse DateTime::modify(string
$modifier )Procedural style DateTimefalse date_modify(DateTime
$object , string $modifier )Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by DateTimeImmutable::__construct. Parameters
Return Values
Returns the modified DateTime object for method chaining or Errors/ExceptionsObject Orientated API only: If an invalid Date/Time string is passed, DateMalformedStringException is thrown. Changelog
ExamplesExample #1 DateTime::modify example Object-oriented style
Procedural style
The above examples will output: 2006-12-13 Example #2 Beware when adding or subtracting months
The above example will output: 2001-01-31 2001-03-03 Example #3 All formats of Date and Time are supported
The above example will output: 2023-07-01 00:00 2023-07-03 00:00 2023-07-03 17:30 See Also
|