Home >>PHP Date Time Functions >PHP date_modify() Function
PHP date_modify() function is used to modify or to alter the timestamp of the DateTime object. It returns a DateTime object on success and returns FALSE on failure.
Syntax :
date_modify($object,$modify);
Parameter | Description |
---|---|
object | This is a required parameter. This parameter defines DateTime object returned by date_create(). |
modify | This is a required parameter. This parameter defines a date/time string. |
Here is an example of date_modify() function in PHP:
<html> <body> <?php $date=date_create(); date_modify($date,"+14 days"); echo date_format($date,"d-M-Y"); ?> </body> </html>
Example 2
<html> <body> <?php $date=date_create("01-01-2020"); date_modify($date,"-20 days"); echo date_format($date,"d-M-Y"); ?> </body> </html>