instance method select_time

Ruby on Rails 3.2.22.5

Since v2.2.3

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

select_time(datetime = Time.current, options = {}, html_options = {})

Returns a set of html select-tags (one for hour and minute). You can set :time_separator key to format the output, and the :include_seconds option to include an input for seconds.

If anything is passed in the html_options hash it will be applied to every select tag in the set.

Examples

my_time = Time.now + 5.days + 7.hours + 3.minutes + 14.seconds

# Generates a time select that defaults to the time in my_time.
select_time(my_time)

# Generates a time select that defaults to the current time (no specified time).
select_time()

# Generates a time select that defaults to the time in my_time,
# which has fields separated by ':'.
select_time(my_time, :time_separator => ':')

# Generates a time select that defaults to the time in my_time,
# that also includes an input for seconds.
select_time(my_time, :include_seconds => true)

# Generates a time select that defaults to the time in my_time, that has fields
# separated by ':' and includes an input for seconds.
select_time(my_time, :time_separator => ':', :include_seconds => true)

# Generate a time select field with hours in the AM/PM format
select_time(my_time, :ampm => true)

# Generates a time select with a custom prompt. Use <tt>:prompt</tt> to true for generic prompts.
select_time(my_time, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'})
select_time(my_time, :prompt => {:hour => true}) # generic prompt for hours
select_time(my_time, :prompt => true) # generic prompts for all

Parameters

datetime opt = Time.current
options opt = {}
html_options opt = {}
Source
# File actionpack/lib/action_view/helpers/date_helper.rb, line 425
      def select_time(datetime = Time.current, options = {}, html_options = {})
        DateTimeSelector.new(datetime, options, html_options).select_time
      end

Defined in actionpack/lib/action_view/helpers/date_helper.rb line 425 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::Helpers::DateHelper

Type at least 2 characters to search.

↑↓ navigate · open · esc close