对Extjs中时间的多种处理

1、类型为datetime的json数据处理 (字段类型为datetime)

new Date(parseInt(yourTime.substring(6, yourTime.length - 2))).format('Y-m-d');

eg:{ header: "结算日期", dataIndex: 'PayDate', align: 'left', width: 85, sortable: true, renderer: function (val) { if (val != null) { return '<span style="font-size:12px;">' + new Date(parseInt(val.substring(6, val.length - 2))).format('Y-m-d') + '</span>'; } } }

2、类型为string的json数据处理 (字段类型为string)

 new Date(yourTime.replace(/-/g, "/")).format('Y-m-d');

eg:{ header: "制单日期", dataIndex: 'CreateDate', align: 'left', sortable: true, renderer: function (val) { if (val != null) { return '<span style="font-size:12px;">' + new Date(val.replace(/-/g, "/")).format('Y-m-d') + '</span>'; } } }

3、日期控件获取的值传递到后台

 Ext.util.Format.date(value, 'Y-m-d');

posted on 2014-03-28 15:30  李九妹  阅读(190)  评论(0编辑  收藏  举报