0

I'm currently pulling in the time of an event from Google Calendars, using PHP and Google's Calendar API. Google's API gives the time in a dateTime format:

["COURSE_DATE"]=>
string(25) "2014-09-22T06:00:00-04:00"

I would like for the string to be displayed in the following format:

date("h:i A");

How can I edit the string so that only the time is being displayed?

1 Answers1

0

You should first parse the time using PHP's DateTime, and then format it accordingly.

<?php
date_default_timezone_set('America/Toronto'); // If not set already :)
$courseDate = new DateTime('2014-09-22T06:00:00-04:00');
echo $courseDate->format('h:i A');
?>
ItalyPaleAle
  • 7,185
  • 6
  • 42
  • 69