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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Drop Down Format issue 1

Status
Not open for further replies.

bam720

Technical User
Sep 29, 2005
289
US
Code:
function DateDropDown(){
		echo '<select name="MM">';
		for ($i = 1; $i <= 12; $i++){
    		echo '<option value="';
			printf('%0-2d', $i);
			echo '">';
			printf('%0-2d', $i); 
			echo '</option>';
		}
		echo '</select>/';
		echo '<select name="DD">';
		for ($i = 1; $i <= 31; $i++){
    		echo '<option value="';
			printf('%0-2d', $i);
			echo '">';
			printf('%0-2d', $i); 
			echo '</option>';
		}
		echo '</select>/';
		echo '<select name="YYYY">';
		for ($i = 2005; $i <= 2010; $i++){
    		echo '<option value="';
			printf('%0-2d', $i);
			echo '">';
			printf('%0-2d', $i); 
			echo '</option>';
		}
	  echo '</select>';

I need the day and the month to have the leading 0. as in 01/01/2005 so that i can use it as a legit date data type for mysql database in the form YYYYMMDD
TIA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top