0

I am having an issue with DataTable DateTime function maybe its a bug.

callsminDate = new DateTime($('#callsmin'), {
    format: 'll',
     buttons: {
    clear: true
    }
});

This is my initialization of DateTime on my input #callsmin

Then on change, I filter the table which is working well, just on the first selection it gives me the wrong value;

// Refilter the table
$('#callsmin, #callsmax').on('change', function () {
    callstable.draw();
    mincallsts = moment(callsminDate.val(), "M/D/YYYY").unix();
    maxcallsts = moment(callsmaxDate.val(), "M/D/YYYY").unix();
    console.log(mincallsts);
});

When I first select a Date it gives me hours and seconds too in my timestring, which is 1655493811

Then I choose another Date and back to this date, and it gives me the correct value which is 1655424000 (notice there is no hours and minutes)

It seems as though DateTime is initializing with the hours and minutes initially, then changes to not include the hours and minutes which is what i want.

1 Answers1

0

its not ideal but could you call .trigger("change") to replicate what you did to get it working manually as part of the page load to force it to initialise and then load. I wonder if its the moment.js, have toy tried Date.parse see if that resolves it ? that should still give you the same result

see Convert normal date to unix timestamp

I hope this helps

Patrick Hume
  • 2,064
  • 1
  • 3
  • 11
  • Thanks for your suggestion, Unfortunately this does not help at all. I think the DateTime object needs to be changed iteself – user2787710 Jun 21 '22 at 04:36