PHP date_modify() Function
In this chapter you will learn:
- Definition for PHP date_modify() Function
- Syntax for PHP date_modify() Function
- Parameter for PHP date_modify() Function
- Return value from PHP date_modify() Function
- Example - Add 15 days to the timestamp
Definition
The date_modify() function modifies the timestamp.
Syntax
PHP date_modify() Function has the following syntax.
date_modify(object,modify);
Parameter
Parameter | Is Required | Description |
---|---|---|
object | Required. | DateTime object returned by date_create() |
modify | Required. | Date/time string |
Return
PHP date_modify() Function returns a DateTime object on success. FALSE on failure.
Example
Add 15 days to the timestamp
<?php// j a v a 2 s .co m
$date=date_create("2013-05-01");
date_modify($date,"+15 days");
echo date_format($date,"Y-m-d");
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP date_offset_get() Function
- Syntax for PHP date_offset_get() Function
- Parameter for PHP date_offset_get() Function
- Return value from PHP date_offset_get() Function
- Example - Return the timezone offset for Oslo Norway, Europe in seconds from UTC, winter and summer
Home » PHP Tutorial » PHP Date Functions