bradkenyon Posted September 12, 2008 Share Posted September 12, 2008 here is the code i have right now, to print out the drop downs for month, day, year, hour, minute, am/pm <?php print '<h3>Date of Event</h3>'; //month $m = 1; print '<select name="event_month">'; print '<option>Month</option>'; while($m <= 12){ print '<option value="'.$m.'">'.$m.'</option>'; $m++; } print '</select>'; //day $d = 1; print '<select name="event_day">'; print '<option>Day</option>'; while($d <= 31){ print '<option value="'.$d.'">'.$d.'</option>'; $d++; } print '</select>'; //year print '<select name="event_year">'; print '<option>Year</option> <option value="2008">2008</option> <option value="2009">2009</option>'; print '</select>'; print '<h3>Time of Event</h3>'; //hour $h = 1; print '<select name="event_hour">'; print '<option>Hour</option>'; while($h <= 12){ print '<option value="'.$h.'">'.$h.'</option>'; $h++; } print '</select>'; //minute $min = 1; print '<select name="event_minute">'; print '<option>Minute</option>'; while($min <= 60){ print '<option value="'.$min.'">'.$min.'</option>'; $min++; } print '</select>'; //AM or PM print '<select name="event_am_pm">'; print '<option>AM or PM</option> <option value="AM">AM</option>'; print '</select>'; ?> i was testing for AM or PM, if PM, add 12 onto the hour picked, for military time, and I knew this is a sloppy way of doing this and thought it would be good to ask for help on this. There must be a better way or even a way that is widely used that you could refer me to. I will add a screen shot of what it looks like as well. if($HTTP_POST_VARS['event_am_pm'] == 'pm') { $event_hour_military = $HTTP_POST_VARS['event_hour'] + 12; } $expiredate=$HTTP_POST_VARS['event_year'].'-'.$HTTP_POST_VARS['event_month'].'-'.$HTTP_POST_VARS['event_day'].' '.$event_hour_military.':'.$HTTP_POST_VARS['event_minute'].':00'; As always, thanks in advance. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/123945-solved-trying-to-make-easy-interface-to-enter-event-time-using-drop-downs/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.