dojo日期操作

前端之家收集整理的这篇文章主要介绍了dojo日期操作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<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;

猜你在找的Dojo相关文章