Question

I want jquery timeago only show me the timeago in days ! I meant when passed 30 days it will show me 31,32,32 days and not 1 month. Thanx for your pront answer.

Was it helpful?

Solution

One solution is to modify the plugin to get the behavior you described. Consider line 83 of jquery.timeago.js:

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

As an example, if you change 30 to 40, like so:

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

the plugin will still show "x days ago" up till 39 days ago.

And if you want to disable units bigger than "days" altogether, you could just take out that portion within the assignment of words, like so:

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));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top