michaelmcgurk
michaelmcgurk

Reputation: 6509

Format DateTime with PHP

My API outputs the DateTime in the following format: 2018-06-17T09:07:00Z

How do I display this in a more meaningful way, say, 17/06/2018.

I looked at the Manual: http://php.net/manual/en/datetime.formats.date.php however still wasn't able to find a way to achieve this.

$eventStart = "2018-06-17T09:07:00Z";

Upvotes: 1

Views: 74

Answers (5)

huks
huks

Reputation: 11

Format the date, but first convert the string to time.

echo date('d/m/Y', strtotime($inputDate));

Upvotes: 1

DsRaj
DsRaj

Reputation: 2328

Convert the string in time and then format the date which you want

Date-Format option

$date = '2018-06-17T09:07:00Z';
echo date('d/m/Y', strtotime($date));

Upvotes: 1

user6299088
user6299088

Reputation:

Use Date Format :

$inputDate = "2018-06-17T09:07:00Z";
echo date('d/m/Y', strtotime($inputDate));

Upvotes: 1

Gaurav Kandpal
Gaurav Kandpal

Reputation: 1310

Use Below code.

date('d/m/Y', strtotime('2018-06-17T09:07:00Z'));

Upvotes: 1

Sinto
Sinto

Reputation: 3997

You can format it like the below code in PHP:

echo date('d/m/Y', strtotime('2018-06-17T09:07:00Z'));

Upvotes: 1

Related Questions