I have a simple News Alert CCK data type, which I've created a view for that generates a simple list for a sidebar block.

Currently it displays:

Performer of the Year first round auditions
7 hours ago
Alumni jazz combo opens benefit concert
5 days 1 hour ago
Enthusiastic response to the debut of Les Miserables
1 week 5 hours ago

I want it to display as:

Performer of the Year first round auditions
7 hours ago
Performer of the Year first round auditions
4 days ago
Alumni jazz combo opens benefit concert
5 days ago
Enthusiastic response to the debut of Les Miserables
1 week ago

In other words, if it's more than 24 hours ago, I don't want the hours to display. It's too much info and clutters the display. Anyone know how to do this?

There may be a way through the Views admin pages. There's an option box under Fields for date fields like the Node Creation, which I'm using, but I don't know what I'd put there to make it work, and I'm not sure this can handle logic like I need here.

I couldn't find a theme function to customize. In the date module there's just a '!time' variable that seems to put the time into the string, which is why I thought of using the option in views to modify this value.

Any help would be great.

Thanks

Comments

czarphanguye’s picture

Good question, I wonder the same. How do you remove the 'seconds' if 23 min 44 sec.

Regards,

Czar

Anonymous’s picture

what you need is to set the granularity. just add '1' as option.

halfiranian’s picture

Just a quick note to say THANK YOU - that was a massively helpful tip...

rcombes’s picture

Could you be more specific about how to set the granularity of the "As Time Ago" date format? I don't see anywhere to add '1' as an option. All I'm presented with is when editing a Content field containing a date is the four checkboxes (Exclude from display, Rewrite output of field, Output field as link, Trim this field..., and Link this field...), the set of Label radio buttons, and the Format drop down.

Cheers

obrienmd’s picture

Agreed, I do not see how to set granularity!

obrienmd’s picture

ping

alexiosc’s picture

On Drupal 7.4, once you select ‘Time Ago’ or ‘Time Ago (with "ago" appended)’, you'll get a ‘Custom date format’ field. Put the 1 in that field.

The help string for the field says so, but I missed it too in the beginning:

If "Custom", see the PHP docs for date formats. If "Time ago", enter the number of different time units to display, which defaults to 2.

sokrplare’s picture

I couldn't find it in the Content Type pages or the Views so ended up finding this thread on how to make the modification in the core and in the date module:
http://drupal.org/node/358219

Far less than ideal, but I needed something that worked!

sukh.singh’s picture

Awesome suggestion.

Marko B’s picture