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