C# 返回json结果集,js日期格式化
2016-12-23 09:51
309 查看
asp.net mvc返回json结果集
[/code]返回的时间格式为"/Date(1381748820000)/"这个时候在easyui的datagrid列项需要按如下代码进行格式化
[/code]当然还需要对js的Date扩展format方法。
[/code]
来自为知笔记(Wiz)
return Json(new
{
total = totalCount,
rows = result
}, JsonRequestBehavior.AllowGet);
[/code]返回的时间格式为"/Date(1381748820000)/"这个时候在easyui的datagrid列项需要按如下代码进行格式化
title: '手术时间', field: 'OPERATION_DATE_TIME', width: 120 [code] , formatter: function (value, rec) {
if (value == null)
return value;
var date = new Date(parseInt(value.substr(6)));
return date.format("yyyy-MM-dd hh:mm");
}
[/code]当然还需要对js的Date扩展format方法。
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
[/code]
来自为知笔记(Wiz)
相关文章推荐
- SpringMVC返回JSON数据时日期格式化问题
- json返回日期格式化的解决
- 关于json返回日期格式化的解决方案
- json返回日期格式化的解决
- 用JS将json日期格式化成正常日期
- Spring3.1返回Json时格式化日期Date
- springmvc 返回json数据日期格式化方法
- js解析格式化json日期
- JS处理json日期格式化问题
- c#json如何格式化日期和时间
- js返回格式化日期
- WebApi 返回小驼峰式 json 格式,并格式化日期
- json返回日期格式化
- 关于json返回日期格式化的解决方案
- 源代码格式化工具推荐(coolformat),可以实现c,c++,c#,java,js,json,html,sql等的格式化
- Spring3.1返回Json时格式化日期Date
- SpringMVC返回JSON数据时日期格式化问题
- WebApi 返回小驼峰式 json 格式,并格式化日期
- spingmvc 返回json数据日期格式化方法
- .Net Json序列化日期/Date(xxxx)/的Js转化&C#转化