我正在使用联系表格7插件。我有两个日期字段-date-from
和date-to
。当我单击date-to
时,我必须使用jquery函数计算date-from
和date-to
之间的差。如果超过6个月-可以,但是如果少于6个月,我必须显示错误消息。问题是当我尝试检查比较日期时,我发现错误DateTime is not a function
或strtotime is not a function
。如何检查date-from
和date-to
之间的差异?
<div class="col-xs-12 col-sm-3">
<label> Date From: <span style="color: red"> * </span>
[date date-from id:date-from]</label>
</div>
<div class="col-xs-12 col-sm-3">
<label> Date to: <span style="color: red"> * </span>
[date date-to id:date-to]</label>
</div>
</div>
和jQuery
$dateto.blur(function(datefrom, dateto){
var date1 = new Date(2010, 6, 17);
var date2 = new Date(2013, 12, 18);
var diff = new Date(date2.getTime() - date1.getTime());
console.log(diff.getUTCMonth());
});
//在这里,我捕获到错误getTime is not a function