Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to count days between two dates in javascript
    primarykey
    data
    text
    <p>this javascript calculate worng number of the days </p> <p>i select two dates </p> <p>1st date 2013-01-01 2nd date 2013-12-31</p> <p>and it is showing worng answer 365 days</p> <p>i was calculte manual it is worng correct answer is 364 days</p> <p>how can i fix this issue please help me thanks</p> <p><strong><a href="http://jsfiddle.net/BXMv6/3/" rel="nofollow">live demo</a></strong></p> <p>form</p> <pre><code>&lt;input class='fromdate' /&gt; &lt;input class='todate' /&gt; &lt;input class='calculated' /&gt; &lt;input class='minim' /&gt;&lt;br/&gt;&lt;p&gt;&lt;font size="3"&gt;&lt;b&gt;For more FAQs Visit&lt;a target="_blank"href="http://jqfaq.com/"&lt;/a&gt; JQFaq.com&lt;/b&gt;&lt;/font&gt;&lt;/p&gt; &lt;iframe id="iframe1" src="http://jqfaq.com/AdPage.html" style="width:100%; height:115px; border:none;" /&gt; </code></pre> <p>javascript</p> <pre><code>$('.fromdate').datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true, }); $('.todate').datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true, }); $('.fromdate').datepicker().bind("change", function () { var minValue = $(this).val(); minValue = $.datepicker.parseDate("yy-mm-dd", minValue); $('.todate').datepicker("option", "minDate", minValue); calculate(); }); $('.todate').datepicker().bind("change", function () { var maxValue = $(this).val(); maxValue = $.datepicker.parseDate("yy-mm-dd", maxValue); $('.fromdate').datepicker("option", "maxDate", maxValue); calculate(); }); function calculate() { var d1 = $('.fromdate').datepicker('getDate'); var d2 = $('.todate').datepicker('getDate'); var diff = 1; if (d1 &amp;&amp; d2) { diff = diff + Math.floor((d2.getTime() - d1.getTime()) / 86400000); // ms per day } $('.calculated').val(diff); $('.minim').val(d1) } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload