Good day, I need to get the number of days between two dates entered into two kendo.DateTimePickers.
My solution always ends with NaN value. RentStartDate and RentEndDate are stored in db as DateTime.
Thank you for your advice.
<script>$("#RentEndDate").change(function () {
var startDate = kendo.toString($("#RentStartDate").data("kendoDateTimePicker").value(), "dd.MM.yyyy");
var endDate = kendo.toString($("#RentEndDate").data("kendoDateTimePicker").value(), "dd.MM.yyyy");
alert(calculate(startDate, endDate));
});
function calculate(first, second) {
var diff = Math.round((second - first) / 1000 / 60 / 60 / 24);
return diff;
}
CreateOrders.cshtml
<h4>Termín půjčení</h4>
<div class="t-col t-col-6 t-col-xs-12 t-col-sm-12 t-col-md-12 col-sm-6">
<label for="rentStartPicker">Půjčit od</label>
@(Html.Kendo().DatePickerFor(model => model.RentStartDate).Name("rentStartPicker").HtmlAttributes(new { style = "height:28px;", required = "required", validationmessage = "Vyberte datum" }))
</div>
<div class="t-col t-col-6 t-col-xs-12 t-col-sm-12 t-col-md-12 col-sm-6">
<label for="rentEndPicker">Půjčit do</label>
@(Html.Kendo().DatePickerFor(model => model.RentEndDate).Name("rentEndPicker").HtmlAttributes(new { style = "height:28px;", required = "required", validationmessage = "Vyberte datum" }))
</div>