Do calculations with bootstrap datepicker -


In my web page, I have some date fields and assign them with the bootstrap date picture has been done. In the javascript function, I need to get the date of the field named "code: onBookingDate". I can like it.

var on_BookingDate = jQuery ('# datepick_onbooking'). Val ();

Then I have to add 8 months for this and then compare the new date value with any other date value which has been obtained using the above method. This is the code I used (all dates are as dd-mm-yyyy )

  var on_BookingDate = jQuery ('# datepick_onbooking'). Val (); Var dateArray = on_BookingDate.split ("-"); // Date is the month value in [1] var dateObj = new date (date is [2], date is [1] - 1, dir array [0]); DateObj.setMonth (dateObj.getMonth () + 8); Var intFreeLastDate = dateObj.getDate () + "-" + (dateObj.getMonth () + 1) + "-" + dateObj.getFullYear ();  

To compare dates, they must be time values ​​

  1. .datepicker ('getDate')
  2. >
  3. > ('GetDate'); Alerts ("int free end date =" + int_free_list_date);

    I get the following error,

      Uncheck type error: there is no undefined function  

    why is it ? And how to fix it.

    JS / post-less "itemprop =" text ">

    I think I'm seeing the problem this row:

     < Code> var int_free_last_date = intFreeLastDate.datepicker ('getDate');  

    .datepicker ('getDate') is using the function is incorrect when you In this way, it is trying to get a date value from the HTML form element. For example, if you called:

      jQuery ('# datepick_onbooking'). Datepicker ('getDate');  

    The date pickup of this ('# datepick_onbooking') element If the intLastFreeDate happens something like 01-02-2015 , then that line will be equivalent to:

     < Code> var int_free_last_date = 01-02-2015 .datepicker ('getDate');  

    You can imagine, which is 01-02-2015 Code> undefined .

    I think that you are close to your solution, you need to format your existing dates in a time value and compare them Need to do :

      var On_bukingdaatetime = On_bukingdtekgettyme (); Var previous freudetime = intLastFreeDate.getTime (); // Compare them but you will  

    Hope this helps!

    Edit

    Since both on_BookingDate and IntFreeLastDate valid date string dd- Mm-yyyy , you can divide them by your - and create a date item, of those items on getTime ( ) , then compare it.

      var temp1 = on_BookingDate.split ("-"); Var temp2 = intFreeLastDate.split ("-"); // [0] is the day, [1] month, [2] year is var date1 = new date (temp1 [2], (temp1 [1] - 1), temp1 [0]); Var date2 = new date (temp2 [2], (temp2 [1] - 1), temp2 [0]); Var time1 = date1.getTime (); Var time2 = date2.getTime (); // Compare them again!  


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -