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.
推荐答案
我刚从这里,并注意到(ex line 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屋!