[英]Checking you have correct Date type at runtime for comparison
OK so it's runtime. 好的,现在是运行时。 You are trying to compare Date's in JavaScript.
您正在尝试比较JavaScript中的日期。 Now sometimes in your code Dates are Strings, sometimes they are Dates and sometimes they are JQuery Objects wrapping around dates - what is returned from
DatePicker.parseDate
see: http://api.jqueryui.com/datepicker/ 现在有时在您的代码中,日期是字符串,有时是日期,有时是环绕日期的JQuery对象-从
DatePicker.parseDate
返回的内容请参见: http : //api.jqueryui.com/datepicker/
So before you just do: 因此,在您执行以下操作之前:
date1 < date2 ...
You want to ensure both dates are in the correct format, JQuery date object ie what is returned from DatePicker.parseDate()
. 您要确保两个日期都采用正确的格式,即JQuery日期对象,即
DatePicker.parseDate()
返回的内容。
What is your suggestion for doing this? 您对此有何建议?
Solution is to do a truthy on the date variables 解决方案是对日期变量做一个真实的判断
eg 例如
myDate.getMonth()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.