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
-
.datepicker ('getDate') - >>
> >> I get the following error, why is it ? And how to fix it.
Uncheck type error: there is no undefined function
JS / post-less "itemprop =" text "> I think I'm seeing the problem this row: The date pickup of this You can imagine, which is < 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'); ('# 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'); 01-02-2015 Code> undefined .
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
Post a Comment