2012-10-03 50 views
1

我想要jquery timeago只显示我在几天的时间!我的意思是,当通过30天时,它会显示我31,32,32天而不是1个月。感谢您的pront答案。Jquery Time Ago only days in

+4

哪个插件?你必须更具体。 – Blender

+0

对不起,我的意思是拔插!我的意思是jquery timeago,你可以在这里找到http://timeago.yarp.com/ – morrisonrox

回答

1

一个解决方案是修改插件以获得您描述的行为。考虑行jquery.timeago.js 83:

days < 30 && substitute($l.days, Math.round(days)) || 

举个例子,如果你改变3040,像这样:

days < 40 && substitute($l.days, Math.round(days)) || 

插件将仍显示 “X天前”直到39天前。

如果要禁用单位比“天”更大的干脆,你可以只取出那部分words分配中,像这样:

var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) || 
      seconds < 90 && substitute($l.minute, 1) || 
      minutes < 45 && substitute($l.minutes, Math.round(minutes)) || 
      minutes < 90 && substitute($l.hour, 1) || 
      hours < 24 && substitute($l.hours, Math.round(hours)) || 
      hours < 42 && substitute($l.day, 1) || 
      substitute($l.days, Math.round(days)); 
+0

hello andrewap! thax为您的答案!它真的帮助我。 – morrisonrox

+0

@morrisonrox你非常欢迎!请考虑通过点击巨大的绿色复选标记来接受我的答案。 – Andrew

+0

其已完成。还有thanx。 – morrisonrox