I'm working on a date range field. The date field only provides you the ability to input a date. I'd like to construct a field that displays the length of time from the date start field and the date end field.

My Use case: The content type is a job. E.g. I worked at that job from january 1, 2001-January 23rd, 2002.

Desired output: e.g. (11 months) or (3 years 2 months)

How do you create a field that calculates the length of duration? Is there a module that currently exists? or would a formatter be needed?

2 Answers 2


I have an idea! How about if you add an additional field to your Job content type called 'Time at job' that's simply a text field.

Then, create a new rule with the rules module that fires off when a Job node is saved or modified. In that rule, you can simply set the 'Time at job' field by calculating its value from the values of the two date fields (using php).

For the php code calculating the length of time between two dates, there are countless of tutorials online. Here's just one that's quite comprehensive: https://stackoverflow.com/questions/676824/how-to-calculate-the-difference-between-two-dates-using-php.

Would that fit your scenario? Calculating a third field upon node save/edit and displaying that instead?


Ended up using the interval field

Interval field gives you a simple field and widget to allow users to enter interval values eg

2 months 3 days 4 years

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.