Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MIlitary Time drop-down box

Status
Not open for further replies.

BettyJo50

Technical User
Apr 25, 2002
47
US
Hi! Can someone PLEASE help me? I am trying to do a drop-down box for military time. I was trying to do it like I did for the Year drop-down box, but I can't seem to get it right. Here is my code for the year drop-down box.

<select name=&quot;select&quot;>
<option value=&quot;&quot;></option>
<? $y = date(Y);
do { ?>
<option>
<?=$y?>
</option>
<? $y = $y - 1;
} while ($y >= 1900);?>
</select>

Is there any way to use this same code by modifying it for Military time? I want to do the hours and the minutes in two separate drop-down boxes. I'm not having any luck figuring it out.

THANK YOU!!! :)
 
Something like this?

[tt]
Code:
<?php

print '<html><body><form><select name=hours>';

for ($counter = 0; $counter < 24; $counter++)
{
	print '<option value='. $counter . '>' . sprintf (&quot;%02d&quot;, $counter) . '</option>';
}

print '</select></form></body></html>';

?>
[/tt] ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top