码迷,mamicode.com
首页 > Web开发 > 详细

json时间格式化问题

时间:2015-04-08 14:27:32      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
 1 function jsonDateFormat(jsonDate) {//json日期格式转换为正常格式
 2 try {
 3 var date = new Date(parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10));
 4 var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
 5 var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
 6 var hours = date.getHours();
 7 var minutes = date.getMinutes();
 8 var seconds = date.getSeconds();
 9 var milliseconds = date.getMilliseconds();
10 return date.getFullYear() + "-" + month + "-" + day;
11 //+ " " + hours + ":" + minutes + ":" + seconds + "." + milliseconds;
12 } catch (ex) {
13 return "";
14 }
15 }
View Code

出自http://www.cnblogs.com/ahjesus

json时间格式化问题

标签:

原文地址:http://www.cnblogs.com/lb12081116/p/4402099.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!