0

I am using a contact form 7 plugin. I have two dates fields - date-from and date-to. When I am clicking on date-to,i must calculate the difference between date-from and date-to with jquery function. If it is more than 6 months - it is ok, but if is less 6 months i must show error message. The problem is when i try to check diff dates, i catch error DateTime is not a function ot strtotime is not a function. How to check difference between date-from and 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>

and the 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());
});

// here i catch error getTime is not a function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.