I am trying to output a users age using the dateofbirth stored in the database in 1984-12-28 format.
The dob is stored in the profiles
I have seen lots of answers but cannot work out where to put the code.
Cheers 🙂
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Add
agemethod to yourUsermodel, which will substractdate_of_birthfromTime.now(). You can also format this so only full years would be returned (that’s usual way to present age anyway). Later in your views just refer to this method.