If you take from the database My past codes were
// get the Shift times $shiftArray=array(); $num=0; $getShiftTimes=mysqli_query($link,"SELECT * FROM shift"); while ($returnShiftTimes = mysqli_fetch_array($getShiftTimes)){ $shiftArray[$num][0]=$returnShiftTimes['shift_id']; $shiftArray[$num][1]=$returnShiftTimes['start_time']; $shiftArray[$num][2]=$returnShiftTimes['end_time']; $num++; } $time = date_format(date_create($shiftArray[0][1]), 'g:i A');
From 14:00:00 will return 2:00 pm
source share