PHP date_create() function

PHP date_create_from_format() Function
PHP date_date_set() function

In this article, you will learn how to create a new DateTime object in PHP. The date_create() function creates a new DateTime Object that is very useful and important for PHP developers because it is required in many functions and also in database columns.

What is the syntax of the date_create() function in PHP?

date_create(time, timezone)
ParametersDetails
timeSpecify the Date/Time string – Required – Null means current Date/Time
timezoneSpecify the Timezone – Optional – Null means current Timezone
PHP date_create() method

Examples of the date_create() function

Example 1. In the following example. we create and return a new DateTime object and then format it according to the specific format.

<?php
$d=date_create("1998-01-04");
echo date_format($d,"Y/m/d");
?>
PHP date_create_from_format() Function
PHP date_date_set() function
en English
X
Scroll to Top