You could try combining the DT Plugin with the Loop Plugin.
This is what your code would look like:
<select id="expiry1">
{exp:for_loop start="0" end="12" increment="1" parse="inward"}
<option value="{exp:dt format='%U' month='{index}'}">
{exp:dt format='%M %Y' month='{index}'}
</option>
{/exp:for_loop}
</select>
To explain how this works:
The start=
and end=
parameters allow us to sequentially loop from a start-end iteration.
We've set the loop to start from 0
which means the first iteration will bemonth="0"
. This comes in handy as the DT Plugin (or most plugins for that matter) disregard zero-value parameters and therefore evaluates it as if the month
parameter were not even provided.
Note: We are also providing the parse="inward"
parameter to the
outer plugin to allow the {index}
variable to parse before DT Plugin
accepts it as a parameter!
Hope this helps!