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

Best Wedding Dresses Australia at AuBridalDresses.com

Find free files to download on allwhatyouwant.net

Advertisement

{html_select_time}

{html_select_time} is a custom function that creates time dropdowns for you. It can display any or all of hour, minute, second and meridian.

The time attribute can have different formats. It can be a unique timestamp, a string of the format YYYYMMDDHHMMSS or a string that is parseable by PHP's strtotime().

Attribute Name Type Required Default Description
prefix string No Time_ What to prefix the var name with
time timestamp No current time What date/time to use
display_hours boolean No TRUE Whether or not to display hours
display_minutes boolean No TRUE Whether or not to display minutes
display_seconds boolean No TRUE Whether or not to display seconds
display_meridian boolean No TRUE Whether or not to display meridian (am/pm)
use_24_hours boolean No TRUE Whether or not to use 24 hour clock
minute_interval integer No 1 Number interval in minute dropdown
second_interval integer No 1 Number interval in second dropdown
field_array string No n/a Outputs values to array of this name
all_extra string No null Adds extra attributes to select/input tags if given
hour_extra string No null Adds extra attributes to select/input tags if given
minute_extra string No null Adds extra attributes to select/input tags if given
second_extra string No null Adds extra attributes to select/input tags if given
meridian_extra string No null Adds extra attributes to select/input tags if given

Example 8.21. {html_select_time}


{html_select_time use_24_hours=true}

  

At 9:20 and 23 seconds in the morning the template above would output:


<select name="Time_Hour">
<option value="00">00</option>
<option value="01">01</option>
... snipped ....
<option value="08">08</option>
<option value="09" selected>09</option>
<option value="10">10</option>
... snipped ....
<option value="22">22</option>
<option value="23">23</option>
</select>
<select name="Time_Minute">
<option value="00">00</option>
<option value="01">01</option>
... snipped ....
<option value="19">19</option>
<option value="20" selected>20</option>
<option value="21">21</option>
... snipped ....
<option value="58">58</option>
<option value="59">59</option>
</select>
<select name="Time_Second">
<option value="00">00</option>
<option value="01">01</option>
... snipped ....
<option value="22">22</option>
<option value="23" selected>23</option>
<option value="24">24</option>
... snipped ....
<option value="58">58</option>
<option value="59">59</option>
</select>
<select name="Time_Meridian">
<option value="am" selected>AM</option>
<option value="pm">PM</option>
</select>

  

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

Comments
by Matthew Waygood on Feb 17, 2012 at 5:50
If you specify an interval, the current value will be rounded down to the nearest value. ie interval 5 with a value of 12 rounds down to 10. It would be nice to be able to choose which direction or method of rounding to use. I am currently using this for a start and end time. Because of the rounding down the end time may not be included in my processing. ie 5:11 to 6:12 - results in 5:10 to 6:10 Including the extra minute for start is fine, but missing out 2 minutes on the end is NOT. Yes, I can add 5 minutes in php, but this defeats the object of using templates.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 6 plus 3? (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
GoDaddy Coupon @buy-hosting.net
First Click Internet Marketing @fcinternetmarketing.com