The date_date_set() function sets a new date.
PHP date_date_set() Function has the following syntax.
date_date_set(object,year,month,day);
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 |
PHP date_date_set() Function returns a new DateTime object on success. FALSE on failure.
Return a new DateTime object, set a new date, and then format the date:
<?php
$date=date_create();
date_date_set($date,2020,10,30);
echo date_format($date,"Y/m/d");
?>
The code above generates the following result.