method

datetime_select

datetime_select(object, method, options = {})
public

Returns a set of select tags (one for year, month, day, hour, and minute) pre-selected for accessing a specified datetime-based attribute (identified by method) on an object assigned to the template (identified by object). Examples:

  datetime_select("post", "written_on")
  datetime_select("post", "written_on", :start_year => 1995)

The selects are prepared for multi-parameter assignment to an Active Record object.

3Notes

See #data_select for available options

theill · Jan 14, 20092 thanks

Available symbols for "options" hash are described on date_select page

Separating date and time

jerome · Aug 3, 2009

Option :datetime_separator can be set too. Default is ' — '

Set hour and/or minutes

beate · Sep 2, 2010

To set the hour and/or the minutes, you can use:

<%= f.datetime_select(:offer_end, :default => { :hour => 23, :minute => 59 }) %>