当前位置 : 主页 > 网页制作 > Dojo >

dojo日期操作

来源:互联网 收集:自由互联 发布时间:2021-06-15
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 上面是声明一个日
<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;
网友评论