我正在尝试计算某个日期之间的天数,我正在使用日期和时间。在 chrome 上工作正常,但在 Firefox 上给了我“NaN”,没有在 Ie 上测试它,但我认为它会得到相同的结果。
<form action="" enctype="multipart/form-data" id="userForm" method="post">
<table border="0">
<tbody>
<tr class="rsform-block rsform-block-paemimodata">
<td>Delivery Date (*)</td>
<td><input type="text" class="datepicker rsform-input-box hasDatepicker" id="paemimodata" name="form[paemimodata]" size="20" value="2013-05-15"></td>
</tr>
<tr class="">
<td>Time (Hours) (*)</td>
<td><select class="rsform-select-box" id="paemimolaikas" name=""><option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
</select>
</td>
</tr>
<tr class="">
<td>Time ( minutes )</td>
<td><select class="rsform-select-box" id="paemimolaikasmin" name="">
<option value="05">05</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="45">45</option>
<option value="50">50</option>
<option value="55">55</option>
<option value="00">00</option>
</select>
</td>
返回日期 ( ) 时间 ( 小时 ) () 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 时间(分钟) 0510 15 20 25 30 35 40 45 50 55 00
</form>
</xmp>
Java 脚本
<pre>
jQuery(function ($) {
function coundays () {
var starter = $('#paemimodata').val();
var starterhour = $('#paemimolaikas').val();
var startermin = $('#paemimolaikasmin').val();
var ender = $('#grazinimodata').val();
var enderhour = $('#grazinimolaikas').val();
var endermin = $('#grazinimolaikasmin').val();
var fullstarter = starter + ' ' + starterhour + ':' + startermin + ':00';
var fullender = ender + ' ' + enderhour + ':' + endermin + ':00';
var start = new Date(fullstarter);
var end = new Date(fullender);
var diff = new Date(end - start);
var days = diff/1000/60/60/24;
alert(days);
};
coundays ();
$('#userForm').on('change', function() {
coundays ();
});
});
</pre>
Js小提琴
http://jsfiddle.net/dezignas/j2HGw/13/
我在这里做错了什么?