I have an entry with a dateOfBirth Date/Time Field.
Is it possible to calculate the current age from that field?
I can't find a craft/twig function/filter to calculate the difference between 2 dates.
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.
Sign up to join this communityI have an entry with a dateOfBirth Date/Time Field.
Is it possible to calculate the current age from that field?
I can't find a craft/twig function/filter to calculate the difference between 2 dates.
Craft's Date/Time field extends PHP's DateTime class so (since 5.3.0) you can use the Diff method like so:
yourDateTimeField.diff(now).format('%y')