c#代码

 public class DateTimeUtil
{
/// <summary>
/// 把json的时间格式还原-服务端
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string Json2Com(string str)
{
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;
}
}

  javascript客户端代码:

 function showDate(val) {
if (val != null) {
val = val.replace("\/Date(", "");
val = val.replace(")/", "");
dt = new Date(Number(val));
return dt.toLocaleString();
} else {
return "";
}
}

  

json时间格式的互换的更多相关文章

  1. JavaScriptSerializer 序列化json 时间格式

    利用JavaScriptSerializer 序列化json 时间格式,得到的DateTime值值显示为“/Date(700000+0500)/”形式的JSON字符串,显然要进行转换 1.利用字符串直 ...

  2. OC处理.Net Json时间格式

    通过服务器收到的json时间格式是/Date(xxxxxxxxxxxxx+xxxx)/,其中前半部分是自1970年的millionSecs,后半部是时区,我们需要对齐进行转换. 解决方式有两种,第一种 ...

  3. net.sf.json 时间格式的转化

    后台代码 //后台代码 response.setCharacterEncoding("UTF-8"); JsonConfig jsonConfig = new JsonConfig ...

  4. Json时间格式转换问题

    很多时候在数据库中取出数据,需要用Json来接收,但是接受出来的数据竟然是:/Date(1386040883000+0800)/ 这种格式. 这个时候就需要将Json格式,转换成Javascript格 ...

  5. obj 转为Json 时间格式自定义

    var tb = evnWarningBll.GatWarning();             var  timeFormat = new IsoDateTimeConverter();       ...

  6. MVC AOP解决JsonResult返回json时间格式

    新建JsonNetResult类:JsonResult public class JsonNetResult: JsonResult { public JsonNetResult() { Settin ...

  7. .net时间格式与彻夜未眠的我

    夜已经很深了,外面的狂风还在呜呜的叫着,我的脚已经冰凉冰凉...从11点半到现在我一直在测试为什么正确的Json格式字符串传到服务器后还在报400错误... 尼玛啊,以前测试是没有问题的啊 事情是这样 ...

  8. Newtonsoft.Json 序列化和反序列化 时间格式【转】

    1.JSON序列化 string JsonStr= JsonConvert.SerializeObject(Entity); eg:   A a=new A(); a.Name="Elain ...

  9. Newtonsoft.Json 序列化和反序列化 时间格式

    From : http://www.cnblogs.com/litian/p/3870975.html 1.JSON序列化 string JsonStr= JsonConvert.SerializeO ...

随机推荐

  1. MySQL检查连接的最大数量和改变的最大连接数

    版权声明:本文博主原创文章.博客,未经同意不得转载.

  2. Codeforces 461B Appleman and Tree(木dp)

    题目链接:Codeforces 461B Appleman and Tree 题目大意:一棵树,以0节点为根节点,给定每一个节点的父亲节点,以及每一个点的颜色(0表示白色,1表示黑色),切断这棵树的k ...

  3. Fckeditor用法

    试Fckeditor版本号:2.6.3 眼下Fckeditor仅仅能用于基于ie内核的浏览器,假设要使用于chrome等浏览器,请使用ckeditor. 详细用法: 1.将解压后的fckeditor整 ...

  4. UITableView的常用方法

    一.UITableView的代理方法 #pragma mark 每一行的高度 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtI ...

  5. 经验总结35--IP地址区域匹配

    想知道客服端訪问的IP地址是多少,并知道区域. 一般能够去http://www.ip138.com/,输入IP查询,但没提供比較好的接口,程序使用不方便. 另外有些企业提供一些离线的IP数据库,能够进 ...

  6. phpStorm+XDebug+chrome 配置

    运行环境: phpStorm 10.0.1 PHP 5.6.24 VC11 x86 Thread Safe Xdebug 2.4.1(PHP 5.6 VC11 TS (32 bit) 1. PHP安装 ...

  7. windows下 composer常见问题及处理

    错误一: Warning: This development build of composer is over 30 days old. It is recommend ed to update i ...

  8. Mvc 导出 Excel

    Mvc 导出 Excel 之前接触过Webform,winfrom 的导出Excel方法 ,优点:省事.缺点:服务器必须安装Office 这几天做项目 和 大牛学习了一下 新的方法,自己加以总结.希望 ...

  9. linux下getrusage()

    #include <sys/resource.h> /* Return resource usage information on process indicated by WHOand ...

  10. git 简单教程更新

    0.初始化 $ git config --global user.name "xxx" $ git config --global user.email "xxx@gma ...