date_create
date_default_timezone_get
Date/Time Functions
PHP Manual

# date_date_set

(PHP 5 >= 5.2.0)

date_date_set — Sets the date

### Description

void date_date_set ( DateTime `$object` , int `$year` , int `$month` , int `$day` )
void DateTime::setDate ( int `$year` , int `$month` , int `$day` )

Resets the current date of the DateTime object to a different date.

### Parameters

`object`

  Procedural style only: A DateTime object returned by date_create()

`year`

  Year of the date.

`month`

  Month of the date.

`day`

  Day of the date.

### Return Values

Returns `NULL` on success or `FALSE` on failure.

### Examples

Example #1 Object oriented example usage

`<?php
date_default_timezone_set('Europe/London');
$datetime = new DateTime('2008-08-03 14:52:10');
$datetime->setDate(2008, 10, 12);
echo $datetime->format(DATE_RFC2822);
?>`

Example #2 Procedural example usage

`<?php
date_default_timezone_set('Europe/London');
$datetime = date_create('2008-08-03 14:52:10');
date_date_set($datetime, 2008, 10, 12);
echo date_format($datetime, DATE_RFC2822);
?>`

The above example will output:

    Sun, 12 Oct 2008 14:52:10 +0100

### See Also

- date_isodate_set()
- date_time_set()

date_create
date_default_timezone_get
Date/Time Functions
PHP Manual