In this example we will explain about PHP set date function.
In this example we will explain about PHP set date function.DateTime::setDate alias date_date_set function is used for resetting the current date of the DateTime object to a different date. It returns the modified DateTime.
Description
public DateTime DateTime::setDate ( int $year, int $month, int $day )
DateTime date_date_set ( DateTime $object, 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.
Examples
<?php
date_default_timezone_set('India/Kolkata');
$datetime = new DateTime('2009-08-24 11:58:10');
$datetime->setDate(2009, 09, 07);
echo $datetime->format(DATE_RFC2822);
?>