Source for file function.html_select_time.php
Documentation is available at function.html_select_time.php
* Smarty {html_select_time} function plugin
* Name: html_select_time<br>
* Purpose: Prints the dropdowns for time selection
* @link http://smarty.php.net/manual/en/language.function.html.select.time.php {html_select_time}
* @uses smarty_make_timestamp()
require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
require_once $smarty->_get_plugin_filepath('function','html_options');
$display_meridian = true;
/* Should the select boxes be part of an array when returned from PHP?
e.g. setting it to "birthday", would create "birthday[Hour]",
"birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]".
Can be combined with prefix. */
$hours = $use_24_hours ? range(0, 23) : range(1, 12);
$hour_fmt = $use_24_hours ? '%H' : '%I';
for ($i = 0, $for_max = count($hours); $i < $for_max; $i++ )
$hours[$i] = sprintf('%02d', $hours[$i]);
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"';
$html_result .= '"' . $prefix . 'Hour"';
if (null !== $hour_extra){
$html_result .= ' ' . $hour_extra;
if (null !== $all_extra){
$html_result .= ' ' . $all_extra;
$html_result .= '>'. "\n";
'selected' => strftime($hour_fmt, $time),
'print_result' => false),
$html_result .= "</select>\n";
$all_minutes = range(0, 59);
for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval)
$minutes[] = sprintf('%02d', $all_minutes[$i]);
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"';
$html_result .= '"' . $prefix . 'Minute"';
if (null !== $minute_extra){
$html_result .= ' ' . $minute_extra;
if (null !== $all_extra){
$html_result .= ' ' . $all_extra;
$html_result .= '>'. "\n";
'print_result' => false),
$html_result .= "</select>\n";
$all_seconds = range(0, 59);
for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval)
$seconds[] = sprintf('%02d', $all_seconds[$i]);
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Second]"';
$html_result .= '"' . $prefix . 'Second"';
if (null !== $second_extra){
$html_result .= ' ' . $second_extra;
if (null !== $all_extra){
$html_result .= ' ' . $all_extra;
$html_result .= '>'. "\n";
'print_result' => false),
$html_result .= "</select>\n";
if ($display_meridian && !$use_24_hours) {
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"';
$html_result .= '"' . $prefix . 'Meridian"';
if (null !== $meridian_extra){
$html_result .= ' ' . $meridian_extra;
if (null !== $all_extra){
$html_result .= ' ' . $all_extra;
$html_result .= '>'. "\n";
'values' => array('am', 'pm'),
'print_result' => false),
$html_result .= "</select>\n";
/* vim: set expandtab: */
|