title: How do I get today's date automatically as an integer in python
body: <p>I want to write a code where it returns user's age when user enters his age in YYYYmmdd format. I have noticed that error lies in the line when I need to get the today's date as an integer but cannot convert strftime to an integer. I am using python 2.7 Any help? thanks!</p>
  
  <pre><code>import datetime
  
  class User(object):
  
      def __init__(self, full_name, birthday):
          self.full_name = full_name
          self.birthday =  birthday
  
      def calculate_age(self):
          """Return the age"""
  
          yyyy = int(self.birthday[0:4])
          mm = int(self.birthday[4:6])
          dd = int(self.birthday[6:8])           
          dob = datetime.date(yyyy, mm, dd)                              
          today = datetime.datetime.today().strftime('%Y%m%d')
          today = int(today)
  
          age_in_days =  (today - dob)
  
          age_in_years = age_in_days / 365
          return int(age_in_years)
  
  def main():
    user_enter = raw_input("Enter your b'day:")
    User1 = User("susa", user_enter)  
    print ("your age is" + User1.calculate_age())
  
  if __name__ == "__main__":
  
      main()
  </code></pre>