The date_date_set() function sets the date into given DateTime object. After this the call object will have new date set.
Syntax
date_date_set ( object, year, month, day )
Parameters
object − DateTime object
year − Year of the date
month − Month of the date
day − Day of the date
Return
The date_date_set() function returns NULL on success or FALSE on failure.
Example
The following is an example −
<?php
$dateSrc = '2017-11-25 11:25 GMT';
$dateTime = date_create( $dateSrc);;
# Now set a new date using date_date_set();
date_date_set( $dateTime, 2000, 12, 12);
echo "New Formatted date is ". $dateTime->format("Y-m-d\TH:i:s\Z");
echo "<br />";
# Using second function.
$dateTime = new DateTime($dateSrc);
$dateTime->setDate( 1999, 10, 12);
echo "New Formatted date is ". $dateTime->format("Y-m-d\TH:i:s\Z");
?>
Output
New Formatted date is 2000-12-12T11:25:00Z New Formatted date is 1999-10-12T11:25:00Z