Computer >> Computer tutorials >  >> Programming >> PHP

date_modify() function in PHP


The date_modify() function alters the timestamp. It returns NULL on success or FALSE on failure.

Syntax

date_modify(object, modify)

Parameters

  • object − DateTime object returned by date_create().

  • modify − Specifies a date/ time string.

Return

The date_modify() function returns NULL on success or FALSE on failure.

Example

The following is an example −

<?php
   $dt = date_create("2018-10-05");
   date_modify($dt,"+5 days");
   echo date_format($dt,"Y-m-d");
?>

Output

The following is the output −

2018-10-10