Skip to content

Instantly share code, notes, and snippets.

@olemb
Last active December 19, 2015 02:58
Show Gist options
  • Save olemb/5886648 to your computer and use it in GitHub Desktop.
Save olemb/5886648 to your computer and use it in GitHub Desktop.
Compute your age in days and years.
#!/usr/bin/python
"""
howoldami - Compute your age in days and years.
Unix has whoami, but it's missing howoldami. No longer!
$ howoldami
You are 15884 days old (or 43.49 years)
- Ole Martin Bjørndalen
"""
import datetime
# Change birth_date to your birth date
birth_date = datetime.date(1970, 1, 1)
today = datetime.date.today()
age_in_days = (today - birth_date).days
age_in_years = age_in_days / 365.25
print('You are {} days old (or {:.2f} years)'.format(
age_in_days, age_in_years))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment