Drupal 7.15 with Date module version 7.x-2.6

Date, Date API, Date Views enabled.

I added a date of birth field to a content type, and added 'child' nodes with their dates of birth.

In Views, I want to see the age of the children, so in the View I have:

Configure field: Content: Date of birth

Formatter = Time ago

Display = Time ago

My problem is this.

Right now, it is Thursday 6 September 2012 1500

A person has Monday 7 September 2009 as their date of birth.

The 'time ago' is showing as 3 years 15 hours ago.

However in real life they haven't yet reached their third birthday, so I want the result to say 2 years until midnight tonight when the child becomes 3.

How can I fix this?

  • My first GUESS is that you are using dates with different granularities, eg the birthdate is entered as YEAR MONTH DAY but NOW is YEAR MONTH DAY HOUR MINUTE. Have you tried looking at/comparing the two dates with just YEAR MONTH DAY granularity?
    – Jimajamma
    Commented Sep 6, 2012 at 16:36
  • You're correct - I am using YEAR MONTH DAY for birthdate. I'm not sure how to do the comparison I need to do in Views so that I compare with YEAR MONTH DAY from NOW.
    – mcaleaa
    Commented Sep 6, 2012 at 18:22
  • D'oh. In the 'time ago' custom date field, put in '1' which will restrict it to 1 field of granularity, in this case X years. The default is 2, which will return X years Y whatevers (in this case hours, but it could be days, weeks, months depending on when it is called.) But realize it will also return months/weeks/days if the child is less than a year old. This doesn't explain why it is off by a year (3 years vs 2)
    – Jimajamma
    Commented Sep 6, 2012 at 18:54
  • I think we're on the right track, but when I set 'Interval' to '1' in the 'Configure field' dialog, I still get the same problem. Today is 2012-09-06, Birthday is 2009-09-07, age is showing as 3 years.
    – mcaleaa
    Commented Sep 6, 2012 at 19:33
  • Grr. We are about to get yelled at for extended chats lol. Timezones the same? Could it be 09-07 "already" where the birthday is?
    – Jimajamma
    Commented Sep 6, 2012 at 19:50

1 Answer 1


The problem is that "Time ago" has no understanding of leap years so when it is calculating an interval it uses a "common year" which is 365 days.

If we go back 30 years ago from today (2018-11-08) to 1988-11-08 and then use a date time calculator we get 30 years exactly, OR 360 months, OR 10957 days.

If the "Time ago" was smart enough to subtract the years, following by the months, followed by the days then it would come up with 30 years, 0 months, and 0 days. The problem is that it does all of its math in days and then tries to convert to years.

10957/365 = 30.019 common years or 30 years and a week. This is because there was 7 leap years between 2018 and 1988...

So there isn't anything wrong per say. It is actually doing exactly what you asked it to do.

You can get much closer if you divide the date by 365.2425 which is the average length of the year of 365.25 which is defined as a Julian year. Julian years are used in astronomy.


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.