3v4l.org

run code in 300+ PHP versions simultaneously
<?php $oldtime = "20:30pm - 23:30pm"; $newtime = explode("-", $oldtime ); $arrStr = []; $arrObj = []; foreach($newtime as $elem) { $o = DateTime::CreateFromformat( 'H:i+',trim($elem) ); $arrObj[] = $o; $arrStr[] = $o->format('g:iA'); } echo join(" - ",$arrStr);

preferences:
27.76 ms | 402 KiB | 5 Q