PHP date_create_from_format() Function

P
PHP date_add() function
PHP date_create() function

In this article, you will learn how to create a new date in a specific format. The PHP date_create_from_format() function creates a new date in the specified format.

What is the syntax of the date_create_from_format() in PHP?

date_create_from_format(format, time, timezone)
ParameterDescription
formatSpecify the format to use – Required
timeDate/time string – Required – Null means current date/time
timezoneThe timezone of time – Optional – Null means current Timezone
PHP date_create_from_format() method

The characters which can be used in the format parameters are as follows.

date and time characters for date functions

Examples of the date_create_from_format() function

Example 1. In the following example, we specify the format to create a new date in this format.

<?php
$date=date_create_from_format("j-M-Y","04-Jan-1998");
?>
PHP date_add() function
PHP date_create() function

Add comment

Tutor Network

Share this

Learn PHP from A to Z