I think it would be quite handy if the Date.module provided a Views field and filter for "Date: Duration" which utilized the option field as a way for users to specify a format_interval() $granularity or a custom date() $format.

Use cases I can think of:

  1. A Nodeprofile Birthdate (date.module) CCK field that appears in views with a "Date: Duration" field labeled "Age" and a granularity of 1 (e.g. 22 or 22 years old)
  2. Same as above plus an external filter which allows people to be narrowed by age range (e.g. 18 - 35 years old)
  3. This may overlap with Calendar.module, but by increasing the format_interval() granularity you could show the time UNTIL or SINCE an event (e.g. 2 hours, 22 minutes)

I might have to end up doing it myself, but thought I would throw it out there in case it's already been done, or someone has already started and wants to share their code, or if someone wants to start before me. :)

Comments

Yura Filimonov’s picture

I second the request.

I want to be able to see the duration of a schedule event, a training session, for example, or a class. E.g. Starts at 9:00, 2 hours. Or, 9:00 - 11:00, specified in one field.

Looking for a better way to display it, too.

Thanks.

Passionate_Lass’s picture

Third!

Bevan’s picture

I have a kind of similar use case by which content items are proposed, unscheduled projects. The duration of construction is known, but not the start date. Valid entries for the content items are: "5 years", "3 months" "2.5 years", "4 years and 3 months". I would like to have these stored in a similar way to ISO date fields, in that I don't want a timestamp, which loses the granularity/precision of the input, and knows if the user input a number of years, month, or for that matter, days, seconds, minutes or hours. Is there a module that does this yet?

Update: Duration module fits these needs quite handsomely, and will suit some of the needs mentioned in this thread such as a "Please enter your age" field.

arlinsandbulte’s picture

Status: Active » Closed (duplicate)
-Mania-’s picture

This would be much needed. Date already has the possibility of displaying a date as 'time ago' when entering fields so why does it not have this in the filter settings? I'm exposing a date field to users and would like them to pick an age value instead of the date.

Levin’s picture

Title: Date views field/filter for Date Duration (e.g. date, elapsed time, etc.) » Date views field/filter for Date Duration (e.g. date, elapsed time, time ago etc.)
Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Closed (duplicate) » Needs review
StatusFileSize
new10 KB
new1.63 KB
new126.08 KB

This patch adds a new feature for the date module which does not exist in current Dev verion (7.x-2.x-dev, 2012-Sep-30). With this patch applied, we can configure “time ago” filter on date fields in views. Please note:

1. The "time ago" field on date fields in views is not implemented in this patch.
2. After applying the patch, you also need to unzip and copy the the file "date_views_time_ago_filter_handler.inc" to sites/all/modules/date/date_views/includes

Attached are the doc and code changes for this patch. Please let me know if you have any comments/questions while using this patch. I'll respond as soon as I can.

Status: Needs review » Needs work

The last submitted patch, date-timeagofilter-218736-6.patch, failed testing.