Javascript help fixing a working time ago date function to simply show seconds ago.

edited, this is it function handleDate( timestamp ) { var n=new Date(), t, ago = " "; if( timestamp ) { t = Math.round( (n.getTime()/1000 - timestamp) ); ago += handleSinceDateEndings( t, timestamp ); } else { ago += ""; } return ago; } function handleSinceDateEndings( t, original_timestamp ) { var ago = " ", date; // If our timestamp is under 60 we are dealing with seconds. if( t < 60 ) { ago += t + " seconds ago"; is_seconds = true; //Otherwise, we are dealing with minutes -- let's adjust t to minutes to avoid //re-writing the rest of the loop. } else { t /= 60; is_seconds = false } if( is_seconds === false ) { if( t<60 ) { ago += Math.round(t) + " mins ago"; } else if( t>= 60 && t<= 120 ) { ago += Math.floor( t / 60 ) + " hour ago" } else if( t<1440 ) { //console.log(t) ago += Math.floor( t / 60 ) + " hours ago"; } else if( t< 2880) { ago += "1 day ago"; } else if( t > 2880 && t

以上就是Javascript help fixing a working time ago date function to simply show seconds ago.的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏