Home >Web Front-end >JS Tutorial >Extjs displays the problem after retrieving time from the database and converting it to JSON_javascript skills

Extjs displays the problem after retrieving time from the database and converting it to JSON_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:48:021370browse

The background retrieves the time from the database, formats it in JSON and then transmits it to the gridpanel. At this time, the time becomes: /Date(32331121223)/. Then the following processing is required to display it normally:
in

Copy code The code is as follows:

var record = Ext.data.Record.create([
{ name: 'PublicDate', mapping: 'PublicDate', dateFormat: 'Y-m-d', convert: function (v) {
if (v == null) {
return null;
}
var d = new Date();
var str = v.toString();
var str1 = str.replace("/Date(", "");
var str2 = str1. replace(")/", "");
var dd = parseInt(str2);
d.setTime(dd);
return d;
} }
]);

Then copy the code in:
The code is as follows:

var cm = new Ext.grid.ColumnModel([
{ header: 'Publication time', dataIndex: 'PublicDate', width: 120, align: 'center', renderer: Ext.util.Format.dateRenderer('Y-m- d') }
]);

This will display normally, such as: 2012-11-19,
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn