Rules date difference
Categories
Component ID
1943938
Component name
Rules date difference
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
Rules Date Difference is a simple action for Rules that accepts two datetime values and calculates the time difference in years. This was created for a project where dates were incompatible with timestamp, that is all dates before 01.01.1970.
The granularity can be easily changed if you want to use days, weeks, months, et.c. Just edit the code in rules_date_difference.rules.inc
, line 34, and swap out 'years' for something else.
$duration = $start_date->difference($end_date, 'years');
More about the date::difference function in the Date API.