Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Generate a dropdown with days of the month (See related posts)

The below code will generate a form dropdown for all the days of the month, with today's day selected. Handy for those date pickers!

<select name="start_day">
<?php
global $LOC;
$current_time_day = $LOC->decode_date('%d', $LOC->now);

for ($i = 1; $i <= 31; $i++) {
   echo "<option value='$i'";
if ($i == $current_time_day) { echo " selected='selected'"; }
   echo ">$i</option>
";
} ?>
</select>

You need to create an account or log in to post comments to this site.


Click here to browse all 5059 code snippets

Related Posts