Time field formatting in snippets

I’m a newbie to Kirby and php, and have inherited a Kirby site that I have been learning how to update. I have created two custom fields (starttime and finishtime) for one of our blueprint pages, which previously used a text field for event time entries. I based the custom fields on the original Kirby time field. I am struggling to properly place the formatting that we want (no leading 0 in 12-format time, and lowercase ‘am’ and ‘pm’ indicators) in my snippets that call up the event content. Here is the snippet code:

$dowMap = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$dow = strftime('%w', $event->date());
echo $dowMap[$dow] . ' | ' . $event->starttime() . ' - ' . $event->finishtime();

The starttime and finishtime fields are what I’m looking to format, and I can’t seem to figure out where to place the format characters to make it work. I’m sure my limited php coding experience is making this more difficult than it needs to me. Any help would be greatly appreciated.

What you are looking for is the date method:

$event->date('FORMAT', 'starttime'); // the 2nd argument is the field name

PHP offers two ways for formatting dates, it depends on which date handler you are using on this project. Check out the PHP docs for help with the formats.