Had to output the difference between two date fields today and wondered if EE could help make this a native feature in the future. Here’s what we ended up doing.
$d1 = new DateTime('{sos_date format="%Y-%m-%d"}');
$d2 = new DateTime('{eos_date format="%Y-%m-%d"}');
$diff = $d2->diff($d1);
echo $diff->y;
Maybe something like this?
{some_date:diff:other_date format="%Y"}
Or some “EE-way” of doing this.
Thanks for listening. LOVE the relative options we have now!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.