标签:color div DDM pts 显示 none serial col script
System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer(); List<Student> list = new List<Student>(); list.Add(new Student() { age = 10, date = DateTime.Now, name = "宋兴柱 是个好孩\"子,这里\"有英文逗号" }); var str = js.Serialize(list); str = Regex.Replace(str, @"\\/Date\((\d+)\)\\/", match => { DateTime dt = new DateTime(1970, 1, 1); dt = dt.AddMilliseconds(long.Parse(match.Groups[1].Value)).ToLocalTime(); return dt.ToString("yyyy-MM-dd HH:mm:ss"); });
原本内容:[{"age":10,"date":"\/Date(1404098342309)\/","name":"宋兴柱 是个好孩\"子,这里\"有英文逗号"}]
显示结果:[{"age":10,"date":"2014-06-30 11:22:15","name":"宋兴柱 是个好孩\"子,这里\"有英文逗号"}]
接收json数据,日期格式为:"\/Date(1414078309687)\/"
var value = "/Date(1414078309687)/"; var da = eval(‘new ‘ + value.replace(‘/‘, ‘‘, ‘g‘)); //或者 var da = value.replace(/\/Date\((\d+)\)\//gi, ‘$1‘); ////通过正则拿到里面数。g 全局 i不区分大小写 da.toLocaleDateString() //2014/10/23 da.toLocaleTimeString() //下午11:31:49
标签:color div DDM pts 显示 none serial col script
原文地址:https://www.cnblogs.com/springsnow/p/11248670.html