[WebMethod(Description = "取得所有人员 自带json")] [SoapHeader("key")] [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)] public string GetRenYuanJSON1() { DuDao.Dal.dc_renyuan dal = new DuDao.Dal.dc_renyuan(); JavaScriptSerializer json = new JavaScriptSerializer(); string str = json.Serialize(dal.GetModelList("", "", null)); str = Regex.Replace(str, @"\\/Date\((\d+)\)\\/", match => { DateTime dt = new DateTime(1970, 1, 1); dt = dt.AddMilliseconds(long.Parse(match.Groups[1].Value)); dt = dt.ToLocalTime(); return dt.ToString("yyyy-MM-dd HH:mm:ss"); }); return str; } //json.net DuDao.Dal.dc_renyuan dal = new DuDao.Dal.dc_renyuan(); var model = dal.GetModel(6); model.login_time = DateTime.Now; //model.login_time = DateTime.Parse(DateTime.Now.ToString());这样返回标准格式 IsoDateTimeConverter dtConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-ddTHH:mm:ss" };//自定义时间格式 return JsonConvert.SerializeObject(model,dtConverter); //JsonConvert.SerializeObject(model,new JavaScriptDateTimeConverter());// new Date(11111) //JsonConvert.SerializeObject(model);//默认时间格式 2016-06-27T14:42:59