PHP date_date_set() Function
Example
Returns a new DateTime object, sets a new date, and then formats the date:
<?php $date=date_create(); date_date_set($date,2020,10,15); echo date_format($date,"Y/m/d"); ?>
Definition and Usage
date_date_set() function sets a new date.
Syntax
date_date_set(object,year,month,day);
parameter | description |
---|---|
object | Required. Specifies by date_create() The returned DateTime object. |
year | Required. Specifies the year in the date. |
month | Required. Specifies the month in the date. |
day | Required. Specifies the day in the date. |
Technical Details
Return Value: | If successful, returns a new DateTime object; if failed, returns FALSE. |
---|---|
PHP Version: | 5.2+ |
Update Log: | Starting from PHP 5.3+, if successful, the return value will change from NULL to DateTime. |