jquery datepicker,日期范围计数
我正在尝试使用 jquery datepicker 来总结或扣除选定范围内的日期,这就是我现在正在做的事情,但没有任何运气。
function test(){
var sundayCheck = 0;
var saturdayCheck = 0;
var totalDays = 0;
sundayCheck = new Date($("#onlySunday").datepicker("getDate"));
saturdayCheck = new Date($("#onlySaturday").datepicker("getDate"));
totalDays = saturdayCheck.getDate() - sundayCheck.getDate();
alert(totalDays);
}
这是一段应该进行计算的代码,但它所做的只是扣除天数,例如
24.01.10 - 06.02.10 = -18,这是完全错误的,因为它应该更多天数,它只是不考虑天数并且只是使用日期的第一个数字。
如果有人可以帮助如何进行此类计算,我将不胜感激。
i am trying to sum up or deduct dates in selected range using jquery datepicker, here is how i am doing it right now but without any luck.
function test(){
var sundayCheck = 0;
var saturdayCheck = 0;
var totalDays = 0;
sundayCheck = new Date($("#onlySunday").datepicker("getDate"));
saturdayCheck = new Date($("#onlySaturday").datepicker("getDate"));
totalDays = saturdayCheck.getDate() - sundayCheck.getDate();
alert(totalDays);
}
thats a piece of code that should make calculation but what it does is just deducts days like,
24.01.10 - 06.02.10 = -18 which is totaly wrong as it should be more days its just does not consider the days and its just using first numbers of dates.
If anyone could help how to make such calculations i would appreciate the most.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否想确定两个日期之间的天数?
首先获取两个日期之间的毫秒数,然后除以一天中的毫秒数。使用 Math.ceil 向上舍入到最接近的整数。
Are you trying to dtermine the number of days between two dates?
First get the number of milliseconds between the two dates then divide by the number of milliseconds in a day. Using Math.ceil to round up to nearest integer.