PHP date_date_set()Functions

PHP Date/TimePHP Date/Time Reference Manual

Examples

Returns a new DateTime object, sets a new date, and then formats the date:

<?php
$date=date_create();
date_date_set($date,2020,10,30);
echo date_format($date,"Y/m/d");
?>

Run Example »

Definition and Usage

The date_date_set() function sets a new date.

Syntax

date_date_set(object,year,month,day);

Parameters Description
object Required. Specifies a ...date_create()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: Returns a new DateTime object on success, or FALSE on failure.
PHP Version: 5.2+
Changelog: As of PHP 5.3+, the return value is changed from NULL to DateTime on success.


PHP Date/TimePHP Date/Time Reference Manual Other Extensions