PHP date_date_set() Function
In this chapter you will learn:
- Definition for PHP date_date_set() Function
- Syntax for PHP date_date_set() Function
- Parameter for PHP date_date_set() Function
- Return for PHP date_date_set() Function
- Example - Return a new DateTime object, set a new date, and then format the date
Definition
The date_date_set() function sets a new date.
Syntax
PHP date_date_set() Function has the following syntax.
date_date_set(object,year,month,day);
Parameter
Parameter | Is Required | Description |
---|---|---|
object | Required. | DateTime object returned by date_create() |
year | Required. | Year of the date |
month | Required. | Month of the date |
day | Required. | Day of the date |
Return
PHP date_date_set() Function returns a new DateTime object on success. FALSE on failure.
Example
Return a new DateTime object, set a new date, and then format the date:
<?php/* j a v a2 s .c om*/
$date=date_create();
date_date_set($date,2020,10,30);
echo date_format($date,"Y/m/d");
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP date_default_timezone_get() Function
- Syntax for PHP date_default_timezone_get() Function
- Return for PHP date_default_timezone_get() Function
- Example - Return the default timezone:
Home » PHP Tutorial » PHP Date Functions