title: ion-datetime - calculate age from birthdate
body: <p>I'm using ion-datetime picker to get the user's date of birth. I want to calculate the user's age based on their input. Not sure why the below isn't working...</p>
  
  <p><strong>html</strong></p>
  
  <pre><code>&lt;ion-datetime [(ngModel)]="userInfo.dateOfBirth"&gt;&lt;/ion-datetime&gt;
  </code></pre>
  
  <p><strong>typescript</strong></p>
  
  <pre><code>public ageFromDOB(dateOfBirth) {
    const today = new Date();
    const birthdate = new Date(dateOfBirth);
    this.userInfo.age = today.getFullYear() - birthdate.getFullYear();
    const month = today.getMonth() - birthdate.getMonth();
    if ( month &lt; 0 || (month === 0 &amp;&amp; today.getDate() &lt; birthdate.getDate())) {
      this.userInfo.age--;
    }
    return this.userInfo.age;
  } 
  </code></pre>