jquery - How can I programmatically set the time value in the Anytime datetimepicker widget? -
i think anytime datetimepicker widget cat's meow (or rolls royce's roar (why key elements of anytime jquery plugin blending in background/invisiblized?)),
i implement way:
html
<label for="begindatetime" class="staticlabel">begin date range</label> <input id="begindatetime" name="begindatetime" required="true" />
jquery
anytime.picker("begindatetime"); var d8 = new date(); d8.sethours(0); d8.setminutes(0); d8.setseconds(0); $('#begindatetime').val(d8);
...but, although setting time zilch/midnight works (sort of) @ first:
(actually, want date , time, not gmt jazz, etc.)
...when mash input element invoke/drop down anytime widget, forgets set zilch, , over[rid,writ]es current time:
how can anytime widget preserve value assign when dropped down (until when , if user changes explicitly, of course)?
update
i tried this:
$( "#begindatetime" ).click(function() { var d = new date(); d.sethours(0); d.setminutes(0); d.setseconds(0); $('#begindatetime').val(d); });
...but difference no val appears in input element until click on - still shows zilch, drops down current time...
update 2
i tried this, too:
anytime.picker("begindatetime", { labelhour: "00", labelminute: "00", labelsecond: "00" });
...but seems nothing.
update 3
ama's answer worked charm. code:
anytime.picker("begindatetime"); // set initial time midnight var convfrom = new anytime.converter(); var d8from = new date(); d8from.sethours(0); d8from.setminutes(0); d8from.setseconds(0); $('#begindatetime').val(convfrom.format(d8from)); anytime.picker("enddatetime"); // set initial time second before midnight var convto = new anytime.converter(); var d8to = new date(); d8to.sethours(23); d8to.setminutes(59); d8to.setseconds(59); $('#enddatetime').val(convto.format(d8to));
...resulted in this:
the picker automatically parses initial value input field, must in correct format. easiest way set value use anytime.converter, example:
var conv = new anytime.converter(); var d8 = new date(); d8.sethours(0); d8.setminutes(0); d8.setseconds(0); $('#begindatetime').val( conv.format(d8) );
Comments
Post a Comment