function toDay(myDate){
var nowDate =new Date();
var myDateO =new Date(myDate);
var s1= nowDate.getTime();
var hour= (s1-myDate)/1000/60/60;
var day=hour/24;
var month=day/30;
var year=month/12;
if(year<1){
if(month<1){
if(day<1){
if(hour<1){
return "刚刚";
}else{
return parseInt(hour)+"小时前";
}
}else{
return parseInt(day)+"天前";
}
}else{
return parseInt(month)+"月前";
}
}else{
return parseInt(year)+"年前";
}
alert(total);
return formatwdate;
}
网友评论