JSon 事件格式化
JS~json日期格式化
起因
对于从C#返回的日期字段,当进行JSON序列化后,在前台JS里显示的并不是真正的日期,需要格式化时间
实现

function ChangeDateFormat(jsondate) {
jsondate = jsondate.replace("/Date(", "").replace(")/", "");
if (jsondate.indexOf("+") > 0) {
jsondate = jsondate.substring(0, jsondate.indexOf("+"));
}
else if (jsondate.indexOf("-") > 0) {
jsondate = jsondate.substring(0, jsondate.indexOf("-"));
}
var date = new Date(parseInt(jsondate, 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
return date.getFullYear()
+ "年"
+ month
+ "月"
+ currentDate
+ "日"
+ " "
+ date.getHours()
+ ":"
+ date.getMinutes();
}
//调用:ChangeDateFormat(data[i].arrDate)

JSon 事件格式化的更多相关文章
- PHP json数据格式化方法
php 的json_encode能把数组转换为json格式的字符串.字符串没有缩进,中文会转为unicode编码,例如\u975a\u4ed4.人阅读比较困难.现在这个方法在json_encode的基 ...
- 在线代码格式化,在线JSON校验格式化
在线代码格式化 http://tool.oschina.net/codeformat/json 在线JSON校验格式化 http://www.kjson.com/ 两个好用工具
- 推荐一个在线json数据格式化网站
json数据非常友好方便的处理: 推荐一个在线json数据格式化网站 http://json.parser.online.fr/
- java 实现JSON数据格式化
关键在于好的算法这个代码来源于网络,算法已在注释中添加. 工具地址: 链接:https://pan.baidu.com/s/1Ns3cqi0SG3qSqatrZBrl4A 提取码:2enp 复制这段内 ...
- 转 Json数据格式化
/// <summary> /// JSON字符串格式化 /// </summary> /// <param name="json"></ ...
- json在线格式化校验
推荐个在线工具箱,json在线格式化转换编码,挺好用的 https://www.codejson.com/
- SpringBoot中使用Fastjson/Jackson对JSON序列化格式化输出的若干问题
来源 :https://my.oschina.net/Adven/blog/3036567 使用springboot-web编写rest接口,接口需要返回json数据,目前国内比较常用的fastjso ...
- 在JAVA中把JSON数据格式化输出到控制台
public class ForMatJSONStr { public static void main(String[] args) { String jsonStr = "{\" ...
- JSON代码格式化 进行查询筛选
JSON是前端编程经常用到的格式,对于PHP或者Python,解析JSON都不是什么大事,尤其是PHP的json_encode和json_decode,干的相当的漂亮.Linux下也有处理处理JSON ...
随机推荐
- Eclipse如何解决启动慢
一般在不对eclipse进行相关设置的时候,使用eclipse总是会觉得启动好慢,用起来好卡,其实只要对eclipse的相关参数进行一些配置,就会有很大的改善. 加快启动速度 1.在eclipse启 ...
- Android:关于声明文件中android:process属性说明
笔者在学习Android Service组件的过程中碰到了一个问题,就是在Android应用的声明文件Manifest.xml中有时候会对相关的服务标签设置一个android:process=&quo ...
- LinkedList子类与Queue接口
LinkedList表示的是一个链表的操作类.定义如下: public class LinkedList<E> extends AbstractSequentialList<E> ...
- Iterator遍历器 调用Symbol.Iterator属性,遍历器对象。
Iterator实现原理 创建一个指针对象,指向当前数据结构的起始位置.也就是说,遍历器对象本质上,就是一个指针对象. 第一次调用指针对象的next方法,可以将指针指向数据结构的第一个成员. 第二次调 ...
- win7 远程桌面关机
在任务管理器中, 打开运行窗口, 执行 shutdown -s 命令, 将在30秒后关闭win7, 如果需要更快, 加上 -t 10 参数 关于 shutdown 的命令行说明: C:\Users\R ...
- 【MySql】C#数据库备份与还原
public static class SQLBackup { /// <summary> /// 执行Cmd命令 /// </summary> /// <param n ...
- Activity中获取view的高度和宽度为0的原因以及解决方案
在activity中可以调用View.getWidth.View.getHeight().View.getMeasuredWidth() .View.getgetMeasuredHeight()来获得 ...
- node基础03:使用函数
1.使用函数 //server.js var http = require("http"); var output = require("./output"); ...
- swift---不同字体大小不同颜色label富文本设置
agreeDeal = UILabel() //富文本,不同字体颜色大小和颜色 let labelString = "登录注册,表示您同意<服务条款及隐私政策>"as ...
- CSS实现透明边框
border: 8px solid rgba(255,255,255,0.2);