截取年月日
var time = data.goods[i].start_date
var year=time.substr(0,4);
var index1=time.indexOf("-");
var index2=time.lastIndexOf("-");
var cha=parseInt(index2)-(parseInt(index1)+1);
var month=time.substr((parseInt(index1)+1),cha);
var kg=time.indexOf(" ");
cha=parseInt(kg)-parseInt(index2);
var day=time.substr(parseInt(index2)+1,cha);
var start_date = year +'-'+ month +'-'+ day
console.log(start_date)
var mh=time.indexOf(":");
cha=parseInt(mh)-(parseInt(kg)+1);
var hour=time.substr(parseInt(kg)+1,cha);
console.log(hour);
var mh2=time.lastIndexOf(":");
cha=parseInt(mh2)-(parseInt(mh)+1);
var hour=time.substr(parseInt(mh)+1,cha);
console.log(hour);
var mh2=time.lastIndexOf(":");
var hour=time.substr(parseInt(mh2)+1);
console.log(hour);
时间戳转换时间
var addtime = new Date( 1569400884 * 1000) ;
addtime = addtime.toLocaleString();
时间戳转换年月日
var addtime = new Date(data.news[i].addtime * 1000).toLocaleDateString()
jq接收数据渲染页面
for (var i = 1; i < data.news.length; i++) {
console.log(data.news[i].title)
var addtime = new Date( data.news[i].addtime * 1000) ;
addtime = addtime.toLocaleString();
console.log(addtime);
var add_div = '<div class="main main_heart">'+'<p>'+data.news[i].title+'</p>'+'<span class="main_cent" style="margin:0;">'+'<img src='+data.news[i].thumb +'>'+'<div class="main_foot clearfix">'+'<ul>'+'<li>'+data.news[i].catid+'</li>'+'<li>'+data.news[i].catid+'</li>'+'<li>'+addtime+'</li>'+'</ul>'+'</div>'+'</span>'+
'</div>';
$('#main_heart').append(add_div);
}