PHP date_date_set() Function
Definition
The date_date_set() function sets a new date.
Syntax
PHP date_date_set() Function has the following syntax.
date_date_set(object,year,month,day);
Parameter
Parameter | Is Required | Description |
---|---|---|
object | Required. | DateTime object returned by date_create() |
year | Required. | Year of the date |
month | Required. | Month of the date |
day | Required. | Day of the date |
Return
PHP date_date_set() Function returns a new DateTime object on success. FALSE on failure.
Example
Return a new DateTime object, set a new date, and then format the date:
<?php/*from w w w . jav a 2 s.c om*/
$date=date_create();
date_date_set($date,2020,10,30);
echo date_format($date,"Y/m/d");
?>
The code above generates the following result.