我是很懒的,不想多说,所以直接上代码。亲们懂的。

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>JsonDate/Json格式的日期格式化列子</title>
</head>
<body>
<script>
Date.prototype.format = function (format) {
var o = {
“M+”: this.getMonth() + 1, //month
“d+”: this.getDate(), //day
“h+”: this.getHours(), //hour
“m+”: this.getMinutes(), //minute
“s+”: this.getSeconds(), //second
“q+”: Math.floor((this.getMonth() + 3) / 3), //quarter
“S”: this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + “”).substr(4 – RegExp.$1.length));
for (var k in o) if (new RegExp(“(” + k + “)”).test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
(“00″ + o[k]).substr((“” + o[k]).length));
return format;
}
function backDate(JSONDateString) {
var date = new Date(parseInt(JSONDateString.replace(“/Date(“, “”).replace(“)/”, “”), 10));
return date;
}

var jsonDate=’\/Date(1376880279000)\/’;
jsonDate = backDate(jsonDate);
console.log(jsonDate);
jsonDate = jsonDate.format(‘yyyy年MM月dd日 hh:mm:ss’);
console.log(jsonDate);
</script>
</body>
</html>

JSON Date Format/JSON 日期格式方法分享的更多相关文章

  1. python判断字符串是否是json格式方法分享

    python判断字符串是否是json格式方法分享 在实际工作中,有时候需要对判断字符串是否为合法的json格式 解决方法使用json.loads,这样更加符合'Pythonic'写法 代码示例:   ...

  2. 工具类:关于解决数据库中的日期格式,经过response.getWriter().write(json)打到前台日期格式混乱的问题的总结

    经过response.getWriter().write(json)打到前台日期格式混乱的问题的总结 import java.text.SimpleDateFormat;import net.sf.j ...

  3. json-lib date对象转json ,加入自定义日期格式处理

    import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import net.sf.json.processors.JsonValu ...

  4. MVC解决Json DataGrid返回的日期格式是/Date(20130450000365)

    实际上是Json格式化问题,我们应该在返回json的时候进行格式化,我们需要重写系统的JsonResult类 using System; using System.Collections.Generi ...

  5. .Net Core WebApi返回的json数据,自定义日期格式

    基本上所有的人都在DateTime类型的字段,被序列化成json的时候,遇到过可恨的Date(1294499956278+0800):但是又苦于不能全局格式化设置,比较难受.以往的方式,要么使用全局的 ...

  6. ASP.Net Core 返回的json数据,自定义日期格式

    //代码位置:Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddMvc() .Ad ...

  7. js 将long日期格式 转换为标准日期格式方法

    我们经常在操作的时候会发现从后台传递到view层的json中datetime类型变成了long型,当然你也可以从后台先转为string类型,但是如果是从和数据库对应的object中封装的话,就不能再去 ...

  8. Date类与日期格式

    Date类概述: 表示特定的瞬间,精确到毫秒. Date()分配 Date 对象并初始化此对象,以表示分配它的时间(精确到毫秒).Date(long date)分配 Date 对象并初始化此对象,以表 ...

  9. javascript Date format(js日期格式化) (转)

    方法一:这个很不错,好像是 csdn 的 Meizz 写的: // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) ...

随机推荐

  1. HDU 5112 A Curious Matt 水题

    A Curious Matt Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...

  2. 离线安装Cloudera Manager5.3.4与CDH5.3.4(二)

    Cloudera Manager Server和Agent所有后发先至.也能够进行CDH5的安装和配置. 然后,主节点可以通过浏览器访问7180port测试(因为CM Server需要花时间来启动,可 ...

  3. Android Settings 导入eclipse

    1.加载源码 Android Project from Existing Code 选择源码工程Settings: 2.加载所需要的jar包 (改下名字) out/target/common/obj/ ...

  4. Linux内核学习笔记2

    http://www.cnblogs.com/bastard/category/412387.html

  5. html5中viewport使用

    html5中viewport使用 转载自:http://www.maoegg.com/the-usage-of-viewport-in-html5/ 用html5开发移动应用时往往会遇到手机的分辨率或 ...

  6. CLI Console

    CLI Console New to 3.0 is a command line utility aptly named Nova located in the root. It currently ...

  7. Using zend-navigation in your Album Module

    Using zend-navigation in your Album Module In this tutorial we will use the zend-navigation componen ...

  8. Android_SeekBar

    xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:too ...

  9. MyBatis6:MyBatis集成Spring事务管理(下篇)

    前言 前一篇文章<MyBatis5:MyBatis集成Spring事务管理(上篇)>复习了MyBatis的基本使用以及使用Spring管理MyBatis的事务的做法,本文的目的是在这个的基 ...

  10. 【区间选点问题】uva 10148 - Advertisement

    区间选点问题,即数轴上有n个闭区间[l1i, ri],取尽量少的点,使得每个区间内都至少有一个点. The Department of Recreation has decided that it m ...