【前端】格式化Json传递的日期
2017-10-17 09:35
471 查看
自定义日期类型转化函数ChangeDateFormat,将//Date(1294499956278+0800)//形式的函数转化为2014-5-2形式
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; }
相关文章推荐
- springMVC框架返回JSON到前端日期格式化
- 格式化Json传递的日期
- MVC日期格式化,后台使用Newtonsoft.Json序列化日期,前端使用”f”格式化日期
- ASP.NET WebApi 自带Json返回日期带T无法格式化的问题
- json返回日期格式化
- 将数组格式化成json格式(2 相关日期下的 费用)
- android开发过程中将json日期字符串,转换成JAVA中Date类型格式化字符串
- net.sf.json 日期 时间 格式化 方法
- extjs显示格式化返回JSON格式的日期
- 解决json传递到前端时候的乱码问题;以及解决在servlet中如何输出页面的问题
- MVC 中前端传递Json数据,后端以对象形式接受参数的处理方法
- springMvc 前端用json的方式向后台传递对象数组方法
- 用JS将json日期格式化成正常日期
- java,JsonFormat格式化日期问题
- 怎么在SpringMvc拦截器或者request中取得前端传递过来的Json数据
- JSON中的日期格式化
- 后台返回json格式数据日期格式化
- 对象转JSONArray,JSONObject[包括对象中日期格式化,属性过滤]
- ASP.NET WebApi 自带Json返回日期带T无法格式化的问题
- 转:前端js、jQuery实现日期格式化、字符串格式化