DataTables DateTime()值的问题

发布于 2025-02-08 06:39:29 字数 707 浏览 1 评论 0原文

我对DataTable DateTime功能有问题,也许是一个错误。

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

这是我在输入#callsmin上对DateTime的初始化

,然后在更改中,我过滤了表现良好的表,仅在第一个选择上,它给了我错误的值;

// 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);
});

当我第一次选择一个日期时,它在时间段的时间里也给了我小时和秒的时间,即1655493811,

然后我选择另一个日期,然后返回到这个日期,它为我提供了正确的值,即1655424000(请注意,没有小时和分钟)

似乎DateTime最初是在小时和几分钟初始化的,然后更改为不包括我想要的小时和分钟。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一人独醉 2025-02-15 06:39:29

它不是理想的,但是您可以调用.trigger(“更改”)来复制您的操作以手动工作作为页面加载的一部分,以迫使其初始化然后加载。我想知道这是瞬间。这仍然应该给您相同的结果,

请参见将正常日期转换为UNIX TIMESTAMP

希望这会有所帮助

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文