how can change the numeric to month in words

自古美人都是妖i 提交于 2019-12-23 12:49:43

问题


i need to try for the drop down with name of the month , the day and year in other loop,s

i try to conver the mm loop in string format,example the first month is jan and the value is 1

output will be below

   <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>

ple help me ..


回答1:


You might 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 the time="2011-05-17" parameter to have that date selected.



来源:https://stackoverflow.com/questions/11190250/how-can-change-the-numeric-to-month-in-words

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!