我怎样才能在时间组合框中添加am / pm

I have the time combobox with 30 minutes increment but I am unable to add am/pm in that.

This is the current time format showing (12:00, 12:30, 01:00, 01:30). I want to display time like (12:00pm, 12:30pm, 01:00am, 01:30am).

My code is below:

for($hours=0; $hours<24; $hours++) // the interval for hours is '1'
    for($mins=0; $mins<60; $mins+=15) // the interval for mins is '30'
echo '<option value="'.str_pad($hours,2,'0',STR_PAD_LEFT).':'.str_pad($mins,2,'0',STR_PAD_LEFT).'">'.str_pad($hours,2,'0',STR_PAD_LEFT).':'.str_pad($mins,2,'0',STR_PAD_LEFT).'</option>';

Try adding the following inside your second for

$ampm = ($hours >= 12) ? 'pm' : 'am';

then concat the $ampm to your string.

This won't give you 1:00pm, though, it will give you 13:00 pm based on your current code, so you'll also need to address that