PHP date_date_set() Function

Definition

The date_date_set() function sets a new date.

Syntax

PHP date_date_set() Function has the following syntax.

date_date_set(object,year,month,day);

Parameter

ParameterIs RequiredDescription
objectRequired.DateTime object returned by date_create()
yearRequired.Year of the date
monthRequired.Month of the date
dayRequired.Day of the date

Return

PHP date_date_set() Function returns a new DateTime object on success. FALSE on failure.

Example

Return a new DateTime object, set a new date, and then format the date:


<?php/*from w  w w  . jav a 2  s.c  om*/
$date=date_create();
date_date_set($date,2020,10,30);
echo date_format($date,"Y/m/d");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions