Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

date_date_set()

Example

Return a new DateTime object, set the date to a specified value, and then format it.

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

Definition and Usage

The date_date_set() function updates the date of a DateTime object.

Syntax

date_date_set(object, year, month, day)

Parameter Values

 

Parameter

Description

object

Required. Specifies a DateTime object created 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.

Technical Details

Return Value:

Returns the updated DateTime object on success; FALSE on failure.

PHP Version:

5.2+

PHP Changelog:

In PHP 5.3, the return value was changed from NULL to DateTime on success.