The Age Calculator can determine the age or interval between two dates. The calculated age will be displayed in years, months, weeks, days, hours, minutes, and seconds.
from datetime import datetime def calculate_age(birth_date, current_date): # Calculate the difference between the two dates delta = current_date – birth_date # Calculate years, months, and days years = delta.days // 365 remaining_days = delta.days % 365 months = remaining_days // 30 days = remaining_days % 30 # Calculate weeks weeks = delta.days // 7 # Calculate hours, minutes, and seconds hours