-2

如何找出入住日期和退房日期之间的日期差异。

function Checkdate(id)
{
  var txtCheckinNew = $(id).parents("table").find("#[id$=TransferDate]").val(); //04/30/2013
  var txtCheckoutNew =$(id).parents("table").find("#[id$=TransferDate1]").val(); //05/03/2013
  var diff =   Date(txtCheckoutNew) - Date(txtCheckinNew);
  alert(diff);      
}
4

2 回答 2

1

您可以使用Date.parse

var txtCheckinNew = Date.parse($('#TransferDate').val());
var txtCheckoutNew = Date.parse($('#TransferDate1').val());
alert((txtCheckoutNew-txtCheckinNew)/(24*60*60*1000));

JS小提琴

于 2013-04-29T09:50:38.727 回答
1

请查看 http://jsfiddle.net/2dJAN/1/

<div class="date"></div>

var Date1 = new Date (2008, 7, 25);
var Date2 = new Date (2008, 7, 27);
var one_day = 1000*60*60*24;
var Days = (Date2.getTime() - Date1.getTime())/(one_day)
$('.date').html(Days)
于 2013-04-29T09:52:44.463 回答