JQuery Datepicker 返回的 Date 对象类型 [英] JQuery Datepicker returned Date object type
问题描述
Datepicker 返回的对象类型是什么?假设我有以下内容:
What's the object type returned by Datepicker? Supposing I have the following:
$("#txtbox").datepicker({
onClose: function(date){
//something
}
});
什么是date
?我有兴趣从另一个 Datepicker 读取日期对象进行比较,例如:
What is date
? I'm interested in reading the date object from another Datepicker for comparison, something like:
function(date){
oDate = $("#oDP").datepicker("getDate");
if(oDate == date)
//do one
else if(oDate > date)
//do two
}
然而,这种比较是行不通的.我猜 Date 对象有某种比较方法,但我不知道.我还尝试比较 oDate.toString() > date.toString()
等日期的字符串表示,但无济于事.
However, this kind of comparison is not working. I'm guessing there is some sort of comparison method for Date object, but I don't know. I also tried comparing the String representation of the dates like oDate.toString() > date.toString()
to no avail.
推荐答案
我刚刚从 here 并注意到(前 600 行)作者正在使用 .getTime() 来比较日期,您尝试过吗?
I just downloaded the source from here and noticed (ex line 600) the author is using .getTime() to compare dates, have you tried that?
if (oDate.getTime() > date.getTime()) {
...
}
这也是切线,但你提到你尝试过 oDate.toString() 而我在 例子 作者正在使用 .asString()
Also this is tangential but you mention you tried oDate.toString() while I noticed in the examples the author is using .asString()
这篇关于JQuery Datepicker 返回的 Date 对象类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!