PHP date_date_set () function
PHP Date / Time Reference Manual
Examples
It returns a new DateTime object, setting a new date and date format:
<?php
$date=date_create();
date_date_set($date,2020,10,30);
echo date_format($date,"Y/m/d");
?>
$date=date_create();
date_date_set($date,2020,10,30);
echo date_format($date,"Y/m/d");
?>
Running instance »
Definition and Usage
date_date_set () function to set a new date.
grammar
date_date_set( object,year,month,day);
参数 | 描述 |
---|---|
object | 必需。规定一个由 date_create() 返回的 DateTime 对象。 |
year | 必需。规定日期中的年。 |
month | 必需。规定日期中的月。 |
day | 必需。规定日期中的日。 |
technical details
return value: | If successful, it returns a new DateTime object, if it fails it returns FALSE. |
---|---|
PHP version: | 5.2+ |
Update log: | Starting from PHP 5.3+, if successful, the return value from NULL into DateTime. |
PHP Date / Time Reference Manual