Closed (won't fix)
Project:
Date
Version:
6.x-2.x-dev
Component:
Date API
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Jan 2009 at 15:56 UTC
Updated:
26 Oct 2018 at 02:29 UTC
Jump to comment: Most recent
Comments
Comment #1
ehr commentedI found now a 3rd location, where granularity for "as time ago" is set per default now: In /modules/date/date/date.theme, it is in the function theme_date_time_ago($start_date, $end_date) where date_format_interval($start_date, 2) is called two times with granularity set to 2. Change it to 1 for 1 unit to display.
For better results with 1 unit displayed for "as time ago", you should also change in /includes/common.inc
in function format_interval at line 1219 the format_plural(floor(... to format_plural(round(...
Hope you can understand me, although I'm quite new to drupal, and as far I'm not be able to produce such proper patch format, sometimes cited in issues.
And of course, we all would appreciate a select box for "as time ago"-granularity somewhere, perhaps in CCK or better in the Views module.
Comment #2
dorien commentedThis would be great. It would provide an "age" display from a birthday field.
Comment #3
ehr commentedIn this case it should remain floor(...). But if you point to an event i.e. on the overnext day morning, it definitely should be round() to display 2 days rather than 1. So I think, even with 1 unit displayed, not only granularity but this floor() or round() should be selectable too.
Comment #4
citronica commentedThank you! Very helpful :-)
Comment #5
sokrplare commentedThe date function has been moved into theme/theme.inc
For me, switching the common.inc function to "ceil" instead of "round" gave me what I needed since it was calculating "Days until..."
I'd recommend doing the date theme/theme.inc overwrite in the template.php file so at least there is one less core modification.
See this node for how to do it in template.php (http://drupal.org/node/457740)
Comment #6
barckhoff commentedThis works for me, but I'm also trying to get the "ago" removed from the display also (because, as someone suggested above, I want to display a person's age). According to the code in theme.inc, this is put there by the format_interval function, but when I looked at the format_interval or theme_date_format_interval functions, I didn't see any reference to adding the text "ago".
If anyone else is looking for this, I finally found it in the date_format_interval() function in date_api.module . Unfortunately, I don't think it's possible to override this in the template.php file.
Comment #7
deggertsen commented@barckhoff and @covenantd, thanks for finding that. Too bad that it has to be a core override.
This really is a feature request to allow for setting the granularity for "as time ago" as well as the text that accompanies it. Ideally you would be able to set the granularity and also override the text output so that you could make so that it doesn't have any text. For example: As stated above you may be doing years old and therefore need it set to 1 and the word ago changed to old; you may even want it to simply just show the years ago without any words. There may very well be some other applications that making these changes would allow for.
This would be a great feature to add...
Comment #8
ccrackerjack commentedsubscribe for feature request.
Comment #9
iparsin commentedI wanted to use "As Time Ago" as someone's age as well. After 3 days searching everywhere on web and in Drupal folder, I tried to just get rid of one word. But no luck just like you all said here, there is no corresponding text to "ago" to override, I gave up:( Drupal way is great because most of the features is possibly altered, but not in this case I guess.
Anyone know how-to please help, thanks...
iparsin
Comment #10
vcrkid commentedIs there any plans to add this feature?
Some time has passed since the request and there have been releases, but from what I've gathered through trying it out, this feature hasn't been added. :-(
Comment #11
yazzz.b commentedI'm also just trying to remove the word "ago." Has anyone figured out how to do this one yet?
Comment #12
d.holmen@gmail.com commentedI also need that one removed.
Subscribing
Comment #13
jonathanmd commentedSubscribing
Comment #14
Prine commentedMay not be the optimal solution but this worked for me.
1. Click on Date field in you Fields column
2. Select "time ago" with granularity of 1 (or whatever suits your needs)
3. Open "Rewrite results" and tick "Trim this field to a maximum length"
4. Depending on granularity, count the length of the text (minus the 3 characters for ago) and enter total
5. Tick "Strip HTML tags" (to remove markup for your max length to work properly)
Save.
Like i said not the best, but worked for my needs to display the Age of users in a table without "ago".
Comment #15
Prine commenteddp. Sorry.
Comment #16
damienmckennaUnfortunately the Drupal 6 version of the Date module is no longer supported. That said, we appreciate that you took time to work on this issue. Should this request still be relevant for Drupal 7 please feel free to reopen it. Thank you.