Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Largest classified with thousands of ads at Shoppok

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Find Wedding Dresses Online at Canada from Ca-dresses.com

Find your local domestic cleaner

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Advertisement

{html_select_date}

{html_select_date} is a custom function that creates date dropdowns. It can display any or all of year, month, and day. All parameters that are not in the list below are printed as name/value-pairs inside the <select> tags of day, month and year.

Attribute Name Type Required Default Description
prefix string No Date_ What to prefix the var name with
time timestamp/ YYYY-MM-DD No current time in unix timestamp or YYYY-MM-DD format What date/time to use
start_year string No current year The first year in the dropdown, either year number, or relative to current year (+/- N)
end_year string No same as start_year The last year in the dropdown, either year number, or relative to current year (+/- N)
display_days boolean No TRUE Whether to display days or not
display_months boolean No TRUE Whether to display months or not
display_years boolean No TRUE Whether to display years or not
month_format string No %B What format the month should be in (strftime)
day_format string No %02d What format the day output should be in (sprintf)
day_value_format string No %d What format the day value should be in (sprintf)
year_as_text boolean No FALSE Whether or not to display the year as text
reverse_years boolean No FALSE Display years in reverse order
field_array string No null If a name is given, the select boxes will be drawn such that the results will be returned to PHP in the form of name[Day], name[Year], name[Month].
day_size string No null Adds size attribute to select tag if given
month_size string No null Adds size attribute to select tag if given
year_size string No null Adds size attribute to select tag if given
all_extra string No null Adds extra attributes to all select/input tags if given
day_extra string No null Adds extra attributes to select/input tags if given
month_extra string No null Adds extra attributes to select/input tags if given
year_extra string No null Adds extra attributes to select/input tags if given
field_order string No MDY The order in which to display the fields
field_separator string No \n String printed between different fields
month_value_format string No %m strftime() format of the month values, default is %m for month numbers.
year_empty string No null If supplied then the first element of the year's select-box has this value as it's label and as it's value. This is useful to make the select-box read Please select a year for example. Note that you can use values like -MM-DD as time-attribute to indicate an unselected year.
month_empty string No null If supplied then the first element of the month's select-box has this value as it's label and as it's value. . Note that you can use values like YYYY--DD as time-attribute to indicate an unselected month.
day_empty string No null If supplied then the first element of the day's select-box has this value as it's label and as it's value. Note that you can use values like YYYY-MM- as time-attribute to indicate an unselected day.

Note

There is an useful php function on the date tips page for converting {html_select_date} form values to a timestamp.

Example 8.19. {html_select_date}

Template code


{html_select_date}

  

This will output:


<select name="Date_Month">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
  ..... snipped .....
<option value="10">October</option>
<option value="11">November</option>
<option value="12" selected="selected">December</option>
</select>
<select name="Date_Day">
<option value="1">01</option>
<option value="2">02</option>
<option value="3">03</option>
  ..... snipped .....
<option value="11">11</option>
<option value="12">12</option>
<option value="13" selected="selected">13</option>
<option value="14">14</option>
<option value="15">15</option>
  ..... snipped .....
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="Date_Year">
<option value="2006" selected="selected">2006</option>
</select>

  

Example 8.20. {html_select_date} second example


{* start and end year can be relative to current year *}
{html_select_date prefix='StartDate' time=$time start_year='-5'
   end_year='+1' display_days=false}

  

With 2000 as the current year the output:


<select name="StartDateMonth">
<option value="1">January</option>
<option value="2">February</option>
.... snipped ....
<option value="11">November</option>
<option value="12" selected="selected">December</option>
</select>
<select name="StartDateYear">
<option value="1995">1995</option>
.... snipped ....
<option value="1999">1999</option>
<option value="2000" selected="selected">2000</option>
<option value="2001">2001</option>
</select>

  

See also {html_select_time}, date_format, $smarty.now and the date tips page.

Comments
by anonymous on Mar 20, 2012 at 11:19
Can you add tag <label> to generated code for html_select_date?
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 8 plus 19? (Are you human?)

Advertisement

Sponsors [info]

UK Web Hosting @webhost.uk.net
Best Web Hosting @rshosting.com
Web Hosting UK @webhostinguk.com
Unlimited Web Hosting @infrenion.com
App Entwicklung @morphodo.com
First Click Internet Marketing @fcinternetmarketing.com
Credit Card Processing Company