javascript - Setting default value in bootstrap datetimepicker results in NaN on popup -


i working on project using ruby + bootstrap framework, including bootstrap datetimepicker plugin.

i have field in form thus:

<div class='datetimepicker-input input-group' id='logged_at'>     <input class='form-control' data-format='dd/mm/yyyy hh:mm a' name='logged_at' type='text' value='27/06/2014 05:08 pm'>         <span class='input-group-addon'>             <i class='fa fa-calendar'></i>         </span>     </input> </div> 

as can see, want datetimepicker use dd/mm/yyyy hh:mm a formatting, however, when enter default date , time in value attribute of <input> tag when generating form, , click on calendar icon pop picker, picker window gives me nan in heading , won't let me select date or time.

if however, leave value attribute blank when generating form, popup works fine.

i have noticed if type on default date in field, , swap month , day around, i.e. asmm/dd/yyyy hh:mm a,the popup works fine, i.e. calendar defaults right day, when choose date, displays in input field dd/mm/yyyy hh:mm a.

i wondering if there way have set default date/time in field? populating value attribute seems confusing plugin, appears wanting initial date in mm/dd/yyyy..., happy show dd/mm/yyyy... afterwards.

ok, think have figured 1 out. appears related moment.js bootstrap-datetimepicker relies on date parsing.

without messing around language options, there line in bootstrap-datetimepicker.js (line 222) had changed from:

if (datestr) picker.date = moment(datestr); 

to

if (datestr) picker.date = moment(datestr, picker.format); 

basically had use picker.format second parameter force mention parse entered date using supplied format had in input field.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -