We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

The difference between two dates

Feature Requests

Kurt Deutscher's avatar
Kurt Deutscher
827 posts
6 years ago
Kurt Deutscher's avatar Kurt Deutscher

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!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.