简体   繁体   中英

ActiveAdmin filter date format

Using Rails 6 and ActiveAdmin 2.6, how would I change the time formatting of a date field? More specifically, I have

filter :birthday

for my resource. This results in two datepicker input fields, allowing me to filter for records with a birthday between these two dates. What I want is to format these input values in dd.mm.yyyy, instead of the default yyyy-mm-dd. How can I achieve this?

The solution I found was to add the following to active_admin.js:

$(function() {
  $('.datepicker').on('focus', function() {
    $(this).datepicker('option', 'dateFormat', 'dd.mm.yy');
  });
});

Found fromhttps://groups.google.com/forum/#!topic/activeadmin/5SqgtX1KQnc

See background info here: https://github.com/activeadmin/activeadmin/issues/2285

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM