PHP date_date_set() function

P
PHP date_create() function
PHP date_default_timezone_get() function

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)
ParameterDescription
objectThe Date/Time Object returned by date_create() function- Required
yearSet the year of the date – Required
monthSet the month of the date – Required
daySet the day of the date – Required
PHP date_date_set() method

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");
?>
PHP date_create() function
PHP date_default_timezone_get() function

Add comment

Tutor Network

Share this

Learn PHP from A to Z