1

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";

michaelmcgurk
  • 6,367
  • 23
  • 94
  • 190

5 Answers5

1

You can format it like the below code in PHP:

echo date('d/m/Y', strtotime('2018-06-17T09:07:00Z'));
Sinto
  • 3,915
  • 11
  • 36
  • 70
  • 1
    You are welcome. If you need to do more, please look into this link: https://www.w3schools.com/php/func_date_date_format.asp – Sinto Jun 27 '18 at 05:03
1

Use Below code.

date('d/m/Y', strtotime('2018-06-17T09:07:00Z'));
Gaurav Kandpal
  • 1,250
  • 2
  • 15
  • 33
1

Use Date Format :

$inputDate = "2018-06-17T09:07:00Z";
echo date('d/m/Y', strtotime($inputDate));
Dinesh Ghule
  • 3,423
  • 4
  • 19
  • 39
1

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));
DsRaj
  • 2,288
  • 1
  • 16
  • 26
1

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

echo date('d/m/Y', strtotime($inputDate));
huks
  • 11
  • 2