1
24 hour dropdown select
CGuild1.com > Tips & Tricks > 24 hour dropdown select

24 hour select Drop Down

Quickly copy and paste for a 24 hour drop down select in php.

<select name="">
    <?php for($i = 1; $i <= 23; $i++): ?>
        <option value="<?= $i; ?>"><?= date("h:i A", strtotime("$i:00")); ?></option>
    <?php endfor; ?>
</select>


You can change the $i for a different start and stop time.
example:
$i = 11; $i <= 19
would give you 11:00AM - 7:00 PM

I found this over here at Stackoverflow.
©2024 CGuild1.com