1

I am having an issue where the regular datepicker updates the value on the rails side in this format '2017-09-12 22:49:27', but I am trying to use datetimepicker and its not updating the value, it updates the text field with the format: M/DD/YYYY but not the actual value in the param as I need that in '2017-09-12 22:49:27' format but its staying the same value which is currently MM/DD/YYYY as what's loaded up for the text field and I am getting an undefined value when I try to see the current value:

var selectedDate = $("#from").find(".active").data("day");

Here is the ruby code

= text_field_tag :from_js, l((params[:from].to_datetime or @item.created_at), format: :american_no_time), class: 'form-control input-sm datetimepicker', id:  'from'
= hidden_field_tag :from, l((params[:from].to_datetime or @item.created_at), format: :american_no_time)

= text_field_tag :to_js, l((params[:to].to_datetime or Time.zone.now.to_datetime), format: :american_no_time), class: 'form-control input-sm datetimepicker', id: 'to'
= hidden_field_tag :to, l((params[:to].to_datetime or Time.zone.now.to_datetime), format: :american_no_time)

and here is the current javascript:

var maxDate = new Date();
var minDate = $("#from").val();
$(function () {
  $('#from').datetimepicker({
    format: "M/D/YYYY",
    minDate: minDate,
    maxDate: maxDate,
    pickTime: false
  });

  $('#to').datetimepicker({
    format: "M/D/YYYY",
    minDate: minDate,
    maxDate: maxDate,
    pickTime: false
  });
}); 

Any ideas or suggestions would be appreciated

VincenzoC
  • 30,117
  • 12
  • 90
  • 112
codeNinjaBro
  • 78
  • 10

0 Answers0