momentjs 使用
var now1 = moment( moment().unix()*1000); //获取unix时间戳 需要*1000
var befor_time = moment(1470040905000) ; // 后台接口给的时间戳 //判断小时差
var hour_gap = now1.diff(befor_time,'hours');
if( hour_gap > 12) {
var day=moment(befor_time).format("YYYY-MM-DD") ;
console.log(day)
}else{
console.log(moment(befor_time).fromNow())
}