How to change the month number in words

I need to try for a dropdown with the name of the month, day and year in another loop, s

I am trying to convert a mm loop to a string format, for example, the first month is jan, and the value is 1

the output will be lower

<option value=1>jan</option> 

i use the following code

 <select name="dd" id="dd"> <option value="">Day</option> {for $foo=1 to 31} <option value="{$foo}">{$foo}</option> {/for} </select> <select name="mm" id="mm"> <option value="">Month</option> {for $foo=1 to 12} <option value="{$foo}">{$smarty.now|date_format:"%b"}</option> {/for} </select> <select name="yy" id="yy"> <option value="">Year</option> {for $foo=1970 to {$foo|date_format:"%Y"}} <option value="{$foo}">{$foo}</option> {/for} </select> 

help me..

+4
source share
1 answer

You may be interested in {html_select_date} .

 {html_select_date start_year=1970 month_format="%b" field_order="dmy" field_array="date" prefix="" day_id="dd" month_id="mm" year_id="yy" } 

will generate HTML like

 <select id="dd" name="date[Day]"> <option value="1">01</option><option value="31">31</option> </select> <select id="mm" name="date[Month]"> <option value="01">Jan</option><option value="12">Dec</option> </select> <select id="yy" name="date[Year]"> <option value="1970">1970</option><option selected="selected" value="2012">2012</option> </select> 

Hint: set time="2011-05-17" selected date.

0
source

All Articles