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

it2024-04-22  112

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

 

接口时间格式处理

// GET: api/Test/5 public List<Article> Get(int id) { List<Article> ls = test.Testshow(id); GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Converters.Add( new Newtonsoft.Json.Converters.IsoDateTimeConverter() { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" } ); return ls; }

 

转载于:https://www.cnblogs.com/yjm8023/p/10309865.html

相关资源:数据结构—成绩单生成器
最新回复(0)