Click here to Skip to main content
15,880,956 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello everyone.
So, I am developing a web based application for an airport parking. I am using Twitter bootstrap for the form. To get the date and time range of every enquiry I am using Date Range Picker for Bootstrap. What I would like to do is to dynamically change a label's value called "Total Price" which is found in the booking page based on the Date Range Picker's inputs (located on the top). Browsing their documentation I could not find something similar to my case. The charging rates are 0.01 per hour. For example: In case I am in the process of my enquiry and I choose to drop my car off at Saturday 10 (00:00) and pick it up at Sunday 11 (00:00) the price label should display "24€".

It is my understanding that this might me too much to ask but I tried as far as I could with no result. Thank you in advance.
Posted
Updated 5-Oct-15 13:16pm
v2

1 solution

JavaScript
var startDate = "", endDate = "";

$('#dateTimeRange').daterangepicker({
    "startDate": "09/30/2015",
    "endDate": "10/06/2015"
}, function(start, end, label) {
  //console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
startDate = start.format('YYYY-MM-DD');
endDate = end.format('YYYY-MM-DD');
});

var dateDiff = Math.abs(startDate.getTime() - endDate.getTime()) / 3600000;

// and then perform your operation based on dateDiff.

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900