PHP | date_date_set() Function Last Updated : 31 Aug, 2018 Comments Improve Suggest changes Like Article Like Report The date_date_set() function is an inbuilt function in PHP which is used to set a new Date. This function has four parameters $object, $year, $month and $day and returns DateTime object on success or false on failure. The date_date_set() function is an alias of DateTime::setDate() function. Syntax: date_date_set( $object, $year, $month, $day ) Parameters: This function accepts four parameters as mentioned above and described below: $object: It is a mandatory parameter which is used to specify the DateTime object which is returned by the date_create() function. $year: It is a mandatory parameter which is used to specify the year of the date. $month: It is a mandatory parameter which is used to specify the month of the date. $day: It is a mandatory parameter which is used to specify the day of the date. Return Value:This function returns a new DateTime object on success or FALSE on failure. Below programs illustrate the date_date_set() function in PHP. Program 1: Procedural style to print DateTime. php <?php // Date_create() returns a new DateTime object. $date = date_create(); // date_date_set() function date_date_set($date, 2018, 8, 31); // Print the date in a format echo date_format($date, "Y/m/d"); ?> Output: 2018/08/31 Program 2: Object oriented style to print DateTime. php <?php // Declare DateTime object. $date = new DateTime(); // date_date_set() function $date->setDate(2018, 8, 31); // Print the date in a format echo $date->format('Y/m/d'); ?> Output: 2018/08/31 Related Articles: PHP | date_sun_info() Function PHP | date_sunrise() Function PHP | date_sub() Function Reference: http://php.net/manual/en/function.date-date-set.php Comment More infoAdvertise with us Next Article PHP | date_date_set() Function U ukasp Follow Improve Article Tags : Web Technologies PHP PHP-date-time PHP-function Similar Reads PHP | DateTime setDate() Function The DateTime::setDate() function is an inbuilt function in PHP which is used to reset the current date of DateTime object with the given date-time object. Syntax: Object oriented style: DateTime DateTime::setDate( int $year, int $month, int $day ) Procedural style: DateTime date_date_set( DateTime $ 2 min read PHP | easter_date() Function The easter_date() function is a built-in function in PHP which returns the Easter date in the year passed as an argument. The current year is taken as default year when no arguments are passed as parameter. Syntax: easter_date( $year ) Parameter: The function accepts one optional parameter $year whi 2 min read PHP | date_sunset() Function The date_sunset() is an inbuilt function in PHP which is used to find the sunset time for a specified day and location. Syntax: date_sunset ( $timestamp, $format, $latitude, $longitude, $zenith, $gmtoffset ) Parameters: This function accepts four parameters as mentioned above and described below. $t 2 min read PHP | DateTime sub() Function The DateTime::sub() function is an inbuilt function in PHP which is used to subtract a number of days, months, years, hours, minutes and seconds from a created DateTime object. Syntax: Object oriented style: DateTime DateTime::sub( DateInterval interval ) Procedural style: DateTime date_sub( DateTim 2 min read PHP | date_time_set() Function The date_time_set() function is an inbuilt function in PHP which is used to sets the time. This function resets the current time of the DateTime object to a different time. Syntax: Procedural style: date_time_set( $object, $hour, $minute, $second, $microseconds ) Object oriented style: DateTime::set 2 min read Like