<div id="form" data-dojo-type="dijit/form/Form"> <input name="date" data-dojo-type="dijit/form/DateTextBox"> <input name="time" data-dojo-type="dijit/form/TimeTextBox" data-dojo-props="constraints:{timePattern:'HH:mm:ss'}"> </div>
上面是声明一个日期框和一个时间框,下面给他们赋值显示:
var dateTime = new Date( time.substring(0,19).replace(/-/g,"/") ); var item = {'date' : dateTime,'time' : dateTime}; registry.byId('form').set('value',item);向后台提交前的转换,用"dojo/date/locale"进行格式化
var form = registry.byId("form"); var fDate = locale.format(form.value.date,{selector:'date',datePattern:'yyyy-MM-dd'}); var fTime = locale.format(form.value.time,{selector:'time',timePattern:'HH:mm:ss'}),var fDateTime = fDate + ' ' + fTime;原文链接:https://www.f2er.com/dojo/291176.html