Created
November 25, 2013 03:36
-
-
Save kidach1/7635948 to your computer and use it in GitHub Desktop.
RailsにDateTimePickerを導入する ref: http://qiita.com/kidachi_/items/9f76a27890d96b9f5838
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= f.label :日付 %> | |
<%= f.text_field :created_at, :class => 'datepicker' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import 'bootstrap-datetimepicker'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//= require bootstrap-datetimepicker | |
var data = {'data-format': 'yyyy-MM-dd hh:mm:ss' }; | |
$(function(){ | |
$('.datepicker').attr(data); | |
$('.datepicker').datetimepicker(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 概要 | |
日付だけならjQuery-uiのDatePickerでokだが、今回は日時まで | |
取得したかったので以下のDateTimePickerを使う。 | |
bootstrap-datetimepicker-rails | |
https://github.com/lubieniebieski/bootstrap-datetimepicker-rails | |
※DatePickerなら以下を参照 | |
Rails で jQuery-ui の Date Picker を日本語で表示する場合のメモAdd Star | |
http://d.hatena.ne.jp/CortYuming/20130420/p1 | |
## 流れ | |
Gemfileに追記、bundle install。 | |
```ruby:Gemfile | |
gem 'bootstrap-datetimepicker-rails' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundle install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{'data-format': 'yyyy-MM-dd'} | |
=>2013-11-23 | |
{'data-format': 'yyyy-MM-dd hh:mm:ss'} | |
=>2013-11-23 11:16:46 | |
{'data-format': 'yyyy-MM-dd hh:mm:ss PP'} | |
=>2013-11-23 11:16:46 PM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'bootstrap-datetimepicker-rails' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment