WordPress联系表格7比较日期

时间:2019-03-12 10:05:49

标签: jquery wordpress contact-form-7

我正在使用联系表格7插件。我有两个日期字段-date-fromdate-to。当我单击date-to时,我必须使用jquery函数计算date-fromdate-to之间的差。如果超过6个月-可以,但是如果少于6个月,我必须显示错误消息。问题是当我尝试检查比较日期时,我发现错误DateTime is not a functionstrtotime is not a function。如何检查date-fromdate-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

0 个答案:

没有答案