//时间-倒序显示 年-月-日 时:分
function(timestamp1) {
if(!timestamp1){
return “”;
}
var myDate = new Date();
var timestamp = new Date(timestamp1 );
myDate=myDate.getTime();
timestamp=timestamp.getTime();
var date3=myDate-timestamp;
var days=Math.floor(date3/(2436001000));
var leave1=date3%(2436001000) //计算天数后剩余的毫秒数
var hours=Math.floor(leave1/(36001000));
var leve=date3%(36001000);
var minu=Math.floor(leve/(601000));
if(days == 0&&hours != 0) {
return hours+“小时前”;
}
if(hours==0){
return minu+“分钟前”;
}
else {
var data=Date.parse(timestamp1);
data=new Date(data);
// data.getFullYear()+"-"+
if(data.getHours()){
return data.getFullYear()+"-"+parseInt(data.getMonth()+1)+"-"+data.getDate() + " " + data.getHours()+":"+data.getMinutes();
}else{
return data.getFullYear()+"-"+parseInt(data.getMonth()+1)+"-"+data.getDate();
}
}
}
//时间-倒序显示-多少天前/多少小时前/多少分钟前
function(timestamp1) {
var myDate = new Date();
var timestamp = new Date(timestamp1 );
myDate=myDate.getTime();
timestamp=timestamp.getTime();
var date3=myDate-timestamp;
var days=Math.floor(date3/(2436001000));
var leave1=date3%(2436001000) //计算天数后剩余的毫秒数
var hours=Math.floor(leave1/(36001000));
var leve=date3%(36001000);
var minu=Math.floor(leve/(601000));
// console.log(days,hours,‘shijian’)
// debugger
console.log(days,hours,‘213’)
if(days== 0&&hours != 0) {
return hours+“小时前”;
}
if(hours==0){
return minu+“分钟前”;
}
else {
if(days<7){
return days + “天前”;
}else if(days>=7&&days<30){
var Z=days/7
return parseInt(Z) + “周前”;
}else if(days>=30&&days<360){
var Y=days/30
return parseInt(Y) + “月前”
}else if(days>=360){
var N=days/360
// console.log( ,‘3212’,N)
var N_P=(Math.floor(N * 10)/10).toString().split(’.’)[1]
if(N_P>=9){
return parseInt(N)+1 + “年前”
}else{
return parseInt(N)+1 + “年前”
}
}
}
时间倒叙显示(计算时间 多少天前/多少小时前/多少分钟前 )
最新推荐文章于 2023-05-10 21:48:10 发布