Jump to content

[SOLVED] Adding a 0 before 1,2,3,4 etc in month drop down


dc_jt

Recommended Posts

Hi I have the following drop down which is to display 1-12 for months January to December. (It also contains -- which means no month selected.)

 

However, the months are displayed 1,2,3, 4 etc. How can I get it to be displayed like 01,02,03,04 etc??

 

I tried using printf but not sure whether Ive put it in the right place??

 

Thanks

 

<select name="Endsdatem" class="fmgreynormal">  
<? 
if ($_GET['iPhaseId'] && formatDate($oIndivualPhase->end_date) != '00/00/0000')
{
for ($i=1;$i<=12;$i++)
{?><?
echo "<option value=\"$i\"";

	if ($i == $EndaMonth) echo " selected";
	echo ">".printf(">%02d</option>",$i);
} ?>
<option value="00">--</option>
<?php } else {
for ($i=1;$i<=12;$i++)
	{
		echo "<option value=\"$i\">$i</option>";
	}
		echo "<option value=\"--\" selected>--</option>";
}
?>
</select> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.