Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in date format from dd/mm/yyyy to yyyy-mm-dd in filter #2690

Open
Dhamodharan02 opened this issue Oct 12, 2023 · 1 comment
Open

Change in date format from dd/mm/yyyy to yyyy-mm-dd in filter #2690

Dhamodharan02 opened this issue Oct 12, 2023 · 1 comment

Comments

@Dhamodharan02
Copy link

Expected behaviour

Tell us what should happen.
In my project, filter is used to show the bookings between from and to dates, for that date picker is used to get the from and to date, while choosing the date in datepicker, it is in this format "dd/mm/yyyy" after filtering the records the format should be displayed in same format like this "dd/mm/yyyy"

Actual behaviour

Tell us what happens instead.
But the format displayed is "yyyy-mm-dd"

Datepicker version used

bootstrap-datepicker-rails (1.10.0.1)

Example code

in _filter_form.html.haml:
= form_for @linguist_filter_form, url: "/account/linguists/filter", method: :post, html: { class: 'form-inline' } do |f|
.form-group
= f.label :with_bookings_from_date, "With bookings from", class: 'sr-only'
.input-group.date#with_bookings_from_date{ data: { behaviour: 'linguist-datepicker' } }
= f.text_field :with_bookings_from_date, value: @linguist_filter_form.with_bookings_from_date, placeholder: 'With bookings from', class: 'form-control', onkeydown: "event.preventDefault()"
%span.input-group-addon
%span.glyphicon.glyphicon-calendar

.form-group
= f.label :with_bookings_to_date, "With bookings to", class: 'sr-only'
.input-group.date#with_bookings_to_date{ data: { behaviour: 'linguist-datepicker' } }
= f.text_field :with_bookings_to_date, value: @linguist_filter_form.with_bookings_to_date, placeholder: 'With bookings to', class: 'form-control', onkeydown: "event.preventDefault()"
%span.input-group-addon
%span.glyphicon.glyphicon-calendar

in linguists.js:

var linguist_datetime_picker = {
initialize: function() {
$("[data-behaviour~='linguist-datetimepicker']").datetimepicker({
useCurrent: false,
locale: 'en-gb',
keepInvalid: true,
showClear: true,
widgetPositioning: {
horizontal: 'auto',
vertical: 'bottom'
}
});
$("[data-behaviour~='linguist-datepicker']").datetimepicker({
dateFormat: 'dd/mm/yyyy',
useCurrent: false,
locale: 'en-gb',
keepInvalid: true,
showClear: true
});
}
};

I also tried these, but nothing worked
value: @linguist_filter_form.with_bookings_to_date.to_fs
value: @linguist_filter_form.with_bookings_to_date.strftime('%d/%m/%Y')
value: @linguist_filter_form.with_bookings_from_date.nil? ? nil : @linguist_filter_form.with_bookings_from_date.strftime('%d/%m/%Y')

= f.text_field :with_bookings_to_date, value: @linguist_filter_form.with_bookings_to_date, placeholder: 'With bookings to', class: 'form-control', data: { date_format: 'DD/MM/YYYY'}

Jsfiddle example to reproduce the problem.
Screenshot 2023-10-12 at 4 34 08 PM
![Screenshot 2023-10-12 at 4 35 44 PM](https://github.com/uxsolutions/bootstrap-da
Screenshot 2023-10-12 at 4 36 11 PM
tepicker/assets/96114251/8bccd675-c908-4fd1-a3a6-d36c5dee2ca6)

@Dhamodharan02
Copy link
Author

Dhamodharan02 commented Oct 12, 2023

Screenshot 2023-10-12 at 4 39 16 PM
In this data-date-format is DD/MM/YYYY and value is 02/10/2023, but it is showing as 2023-10-02 in view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant