【发布时间】:2011-09-07 19:32:08
【问题描述】:
我不知道如何将 wcf 输出的日期时间转换为 ExtJs 可以使用的日期时间。我找到了很多关于此的文章,但它们都是针对 ExtJs 3 的,我无法让它与 4 一起使用。
我确实找到了这段代码,但我不知道如何使用它来转换 JsonStore 中的所有内容。
//this method is used to convert the MS JSON date format to the ExtJS Grid Date Column Value
function dateFormatter(dt) {
/// <summary>this method is used to convert the MS JSON date format to the ExtJS Grid Date Column Value</summary>
/// <param name="dt">Actual JSON Date Value</param>
try {
//microsoft JSON date format needs to convert into Javascript date
var newdata = dt.replace(/\/Date\((-?[0-9]+)([+-][0-9]+)?\)\//g, "new Date($1)");
newdata = eval('(' + newdata + ')');
return newdata.format('m/d/Y');
}
catch (e) {
return dt;
}
}
【问题讨论】: