PHP date_date_set() Function

PHP date_date_set Function


Definition :

PHP date_date_set() Function is inbuilt function in php.PHP date_date_set() function is used to set a new date also with a desired format of the date. It returns a datetime object as output.

Syntax

   date_date_set(object, year, month, day)

Parameter
Parameter Description
object Required. Specifies a DateTime object returned by date_create()
year Required. Specifies the year of the date
month Required. Specifies the month of the date
day Required. Specifies the day of the date

Given below example return a new DateTime object, set a new date, and then format the date : 

Output : 27-Dec-2021