I want to find difference between two dates. I have tried this code but it gives me wrong values. I want get total minutes between two dates, so I am converting hours to min
Try this:
var startDate = new Date('Jan 01 2007 11:00:00');
var endDate = new Date('Jan 01 2007 11:30:00');
var starthour = parseInt(startDate.getHours());
var endhour = parseInt(endDate.getHours());
if(starthour>endhour){
alert('Hours diff:' + parseInt(starthour-endhour));
}
else{
alert('Hours diff:' + parseInt(endhour-starthour));
}
And here is the working fiddle.