I am trying to create a dropdown list for display time. My Option tag should be something like this
<option value="1">01.00AM</option>
<option value="2">02.00AM</option>
<option value="3">03.00AM</option> and so on
So Can I know is there a quick way to create the array instead of typing each hours in option tag?
NOTE: AM and PM should be display according to the time.
I tried it with this code, but it doesn't work for me..
<select>
<?php for($i = 0; $i < 24; $i++): ?>
<option value="<?= $i; ?>"><?= $i % 12 ? $i % 12 : 12 ?>:00 <?= $i >= 12 ? 'pm' : 'am' ?></option>
<?php endfor ?>
</select>