Skip to content

Commit ab17e1a

Browse files
committed
Merge pull request #17 from workgena/readme
Example: change format
2 parents 03cd940 + b0caf3b commit ab17e1a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ ActiveAdminDatetimepicker::Base.default_datetime_picker_options = {
5757
ActiveAdminDatetimepicker::Base.format = "%Y-%m-%d %H:%M:%S"
5858
```
5959

60+
## Change datetime format
61+
If you want to change format - you need to make sure that front-end and back-end formats are identical. And remember JS and Ruby datetime format has different syntax.
62+
63+
Create configuration file '/config/initializers/init_datetimpicker.rb'
64+
65+
```ruby
66+
# Example "11/03/2016 13:00"
67+
ActiveAdminDatetimepicker::Base.default_datetime_picker_options = {
68+
format: 'd/m/Y H:i', # JS format
69+
defaultTime: proc { Time.current.strftime('%H:00') } # not necessary
70+
}
71+
ActiveAdminDatetimepicker::Base.format = "%d/%m/%Y %H:%M" # Ruby format
72+
```
6073

6174
See [the datetimepicker documentation for more details](http://xdsoft.net/jqplugins/datetimepicker/).
6275

0 commit comments

Comments
 (0)