.net中后端接口时间格式处理

int useridx = Convert.ToInt32(context.Request.QueryString["useridx"]);
int type = Convert.ToInt32(context.Request.QueryString["type1"]);

DataTable dt = BLL.ActivitySystem.Get_ShowDatal20181214(bdate, edate, useridx, type);

////时间格式的转化
Newtonsoft.Json.Converters.IsoDateTimeConverter timeFormat = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
timeFormat.DateTimeFormat = "MM-dd HH:mm";
string list = Newtonsoft.Json.JsonConvert.SerializeObject(dt, Newtonsoft.Json.Formatting.Indented, timeFormat);

///转换成json

//string result = JsonConvert.SerializeObject(
//new
//{
// data = new { list = dt },

//});
context.Response.Write(list);

猜你喜欢

转载自www.cnblogs.com/yjm8023/p/10309865.html