In this article, you will learn to set a new date. The date_date_set() PHP function set a new date.
What is the syntax of the function in PHP?
date_date_set(object, year, month, day)
Parameter | Description |
---|---|
object | The Date/Time Object returned by date_create() function- Required |
year | Set the year of the date – Required |
month | Set the month of the date – Required |
day | Set the day of the date – Required |
Examples of the date_date_set() function
Example 1. In the example below, we created a new DateTime object and set a new date with specified format.
<?php
$d=date_create();
date_date_set($d,1998,04,01);
echo date_format($d,"Y/m/d");
?>