对Extjs中时间的多种处理

时间:2023-01-06 14:02:49

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');

相关文章