前台js方式来转换日期毫秒数

公共js方法

var getDateStr=function (myDate){

if(myDate==null){
myDate=new Date();
}
   var str = myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate();
   return str;

}


返回的json

[{"community_id":"","community_name":"创新社区","detail_address":"中坤路","email":"1220532@qq.com","harbor_id":0,"harbor_name":"","password":"","real_id":"410221199310037801","real_name":"张祖源","register_time":{"date":20,"day":1,"hours":22,"minutes":22,"month":2,"seconds":22,"time":1490019742000,"timezoneOffset":-480,"year":117},"role_id":0,"sex":"man","state":0,"tel":"110","type":"","user_id":3,"user_name":"zzy"},{"community_id":"","community_name":"创新社区","detail_address":"中坤路","email":"admin@qq.com","harbor_id":0,"harbor_name":"","password":"","real_id":"41000","real_name":"代振威","register_time":{"date":27,"day":1,"hours":11,"minutes":23,"month":2,"seconds":59,"time":1490585039000,"timezoneOffset":-480,"year":117},"role_id":0,"sex":"男","state":0,"tel":"18838181046","type":"","user_id":33,"user_name":"dzw"},{"community_id":"","community_name":"创新社区","detail_address":"中坤路","email":"admin@qq.com","harbor_id":0,"harbor_name":"","password":"","real_id":"41000","real_name":"代振威","register_time":{"date":27,"day":1,"hours":11,"minutes":26,"month":2,"seconds":28,"time":1490585188000,"timezoneOffset":-480,"year":117},"role_id":0,"sex":"男","state":0,"tel":"18838181046","type":"","user_id":34,"user_name":"dzwgg"}]



var b="<tr><td>"+result[o].user_name+"</td><td>"+result[o].real_name+"</td><td>"+result[o].sex+"</td><td>"+result[o].real_id+"</td><td>"+result[o].email+"</td><td>"+result[o].community_name+"</td><td>"+result[o].tel+"</td><td>"+getDateStr(new Date(result[o].register_time.time))+"</td></tr>"

getDateStr(new Date(result[o].register_time.time))这样调用获得2017-3-20

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值