当前位置: 首页 > 新闻动态 > 软件编程

json格式的时间显示为正常年月日的方法

作者:用户投稿 浏览: 发布日期:2026-01-16
[导读]:json格式的时间显示为:Date(1377828670436)需要转换为正常年月日,具体的实现思路及代码如下,感兴趣的朋友可以参考下
json格式的时间显示为:/Date(1377828670436)/需要转换为正常年月日,方法如下:
复制代码 代码如下:
//通过序列化转换出来的json,如果里面有DateTime格式的,就不会正常显示时间,用下面的方法就可以了
var date=renderTime(json.AddDateTime);
//把读出来的json格式时间传入这个方法内
function renderTime(date){
var da = new Date(parseInt(date.replace("/Date(","").replace(")/","").split("+")[0]));
return da.getFullYear()+"-"+ (da.getMonth()+1)+"-" +da.getDate()+" " +da.getHours()+":"+da.getSeconds()+":"+da.getMinutes();
}
//最后显示时间的格式就是 2012-4-17 22:58 了
免责声明:转载请注明出处:http://shjed.com/news/202706.html

扫一扫高效沟通

多一份参考总有益处

免费领取网站策划SEO优化策划方案

请填写下方表单,我们会尽快与您联系
感谢您的咨询,我们会尽快给您回复!