No commit activity in last 3 years
No release in over 3 years
A library allows to select date and time.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

DateTimePicker¶ ↑

A library allows to select date and time, which uses jQuery UI.

Requirements¶ ↑

You should have jquery-rails gem installed and require jquery and jquery-ui assets (don’t forget to require CSS for your jQuery UI).

Installation¶ ↑

Add this to your Gemfile and run the bundle command

gem 'date_time_picker'

Run generator to create initializer

rails generate date_time_picker

or create file manually and activate date_time_picker inside an initializer:

DateTimePicker.activate :simple_form

You can pass only :simple_form to the activate method.

I18n¶ ↑

By default plugin includes most using locales and you can require them from your application.js or using the helper, but if you want to add your locales or/and change one of them, then just put them into your assets dir.

Usage¶ ↑

To add necessary assets add into your head

<%= date_time_picker_assets %>

Or you can add them manually by requiring date_time_picker and date_time_picker_locale

To use the picker inside the form

<%= f.date_time_picker :datetime %>

To use it outside the form

<%= date_time_picker :datetime %>

To specify special options add them into the end

<%= t.date_time_picker :datetime, :id => 'input_id', :class => [:class_1, :class_2], :ampm => true %>

The full list of available options you can find on the jQuery UI Datepicker docs and jQuery UI Timepicker.

By default plugin uses app locale, but if you want to specify it manually you can do this

<%= t.date_time_picker :datetime, :locale => :ru %>

Also available

<%= date_picker :date_only %>

<%= time_picker :time_only %>

SimpleForm support¶ ↑

To use the picker inside the form

<%= f.input :created_at, as: :ui_date_time %>

Also available

<%= f.input :created_at, as: :ui_date %>

<%= f.input :created_at, as: :ui_time %>