Wednesday, 15 February 2012

javascript - Display number of days between 2 datepicker dates? -



javascript - Display number of days between 2 datepicker dates? -

i looking seek , calculate number of days between 2 datepicker fields , display value in input field. have searched lot of different methods can't seem work. using boostrap-datepicker.js

i have created js fiddle here http://jsfiddle.net/klpq7/201/ can see effort far

my js follows

function days() { var = $("#datepicker_start").datepicker('getdate').gettime(), b = $("#datepicker_end").datepicker('getdate').gettime(), c = 24*60*60*1000, diffdays = math.round(math.abs((a - b)/(c))); $("#totaldays").val(diffdays) } $('.datepicker') .datepicker({format: 'dd, dd.mm.yyyy'}) .on('changedate', function(ev){ $(this).datepicker('hide').blur(); });

in first part trying accomplish this, not working!

looking help...

i have modified jsfiddle correctly calculates differences. 1 think noticed utilize dd/mm/yyyy format , default js wants dates mm/dd/yyyy. best if handle 'american' way date difference calculations, if must utilize 'correct' style of dd/mm/yyyy recommend taking @ globalize library.

javascript jquery twitter-bootstrap datepicker

No comments:

Post a Comment