<p>What is the best way to calculate Age using Flex?</p>

[{'answer_id': 41845, 'author': 'Richard Braxton', 'author_id': 4393, 'author_profile': 'https://Stackoverflow.com/users/4393', 'pm_score': 4, 'selected': False, 'text': '<p>I found an answer at <a href="http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&amp;file=08_Dates_and_times_164_2.html" rel="nofollow noreferrer">the bottom of this page in comments section (which is now offline)</a>. </p>\n\n<blockquote>\n  <p><strong>jpwrunyan said on Apr 30, 2007 at 10:10 PM :</strong></p>\n  \n  <blockquote>\n    <p>By the way, here is how to calculate age in years (only) from DOB without needing to account for leap years:</p>\n  </blockquote>\n</blockquote>\n\n<p>With a slight correction by <a href="https://stackoverflow.com/users/210612/fine-wei-lin">Fine-Wei Lin</a>, the code reads</p>\n\n<pre><code>private function getYearsOld(dob:Date):uint {  \n    var now:Date = new Date();  \n    var yearsOld:uint = Number(now.fullYear) - Number(dob.fullYear);  \n    if (dob.month &gt; now.month || (dob.month == now.month &amp;&amp; dob.date &gt; now.date)) \n    {\n       yearsOld--;\n    }\n    return yearsOld;  \n}\n</code></pre>\n\n<blockquote>\n  <blockquote>\n    <p>This handles most situations where you need to calculate age.  </p>\n  </blockquote>\n</blockquote>\n'}, {'answer_id': 43789, 'author': 'Raleigh Buckner', 'author_id': 1153, 'author_profile': 'https://Stackoverflow.com/users/1153', 'pm_score': 1, 'selected': False, 'text': '<p>You could also do it roughly the same as discussed <a href="https://stackoverflow.com/questions/9/how-do-i-calculate-someones-age-in-c" title="Jeff Atwodd&#39;s Question about calculating age in C#">here</a>: (translated to AS3)</p>\n\n<pre><code>var age:int = (new Date()).fullYear - bDay.fullYear;\nif ((new Date()) &lt; (new Date((bDay.fullYear + age), bDay.month, bDay.date))) age--;\n</code></pre>\n'}, {'answer_id': 542129, 'author': 'Matt MacLean', 'author_id': 22, 'author_profile': 'https://Stackoverflow.com/users/22', 'pm_score': 1, 'selected': False, 'text': '<p>Here is a little more complex calculation, this calculates age in years and months. Example: User is 3 years 2 months old.</p>\n\n<pre><code>private function calculateAge(dob:Date):String {        \n    var now:Date = new Date();\n\n    var ageDays:int = 0;\n    var ageYears:int = 0;\n    var ageRmdr:int = 0;\n\n    var diff:Number = now.getTime()-dob.getTime();\n    ageDays = diff / 86400000;\n    ageYears = Math.floor(ageDays / 365.24);\n    ageRmdr = Math.floor( (ageDays - (ageYears*365.24)) / 30.4375 );\n\n    if ( ageRmdr == 12 ) {\n        ageRmdr = 11;\n    }\n\n    return ageYears + " years " + ageRmdr + " months";\n}\n</code></pre>\n'}, {'answer_id': 542592, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<pre><code>var userDOB : Date = new Date(year,month-1,day);\nvar today : Date = new Date();\n\nvar diff : Date = new Date();\ndiff.setTime( today.getTime() - userDOB.getTime() );\n\nvar userAge : int = diff.getFullYear() - 1970;\n</code></pre>\n'}, {'answer_id': 1269238, 'author': 'datico', 'author_id': 127105, 'author_profile': 'https://Stackoverflow.com/users/127105', 'pm_score': 1, 'selected': False, 'text': "<p>Here's a one-liner:</p>\n\n<pre><code>int( now.getFullYear() - dob.getFullYear() + (now.getMonth() - dob.getMonth())*.01 + (now.getDate() - dob.getDate())*.0001 );\n</code></pre>\n"}, {'answer_id': 2791649, 'author': 'jowie', 'author_id': 190657, 'author_profile': 'https://Stackoverflow.com/users/190657', 'pm_score': 1, 'selected': False, 'text': '<p>I found a few problems with the top answer here. I used a couple of answers here to cobble together something which was accurate (for me anyway, hope for you too!)</p>\n\n<pre><code>private function getYearsOld(dob:Date):uint\n{\n    var now:Date = new Date();\n    var age:Date = new Date(now.getTime() - dob.getTime());\n    var yearsOld:uint = age.getFullYear() - 1970;\n    return yearsOld;\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/41763', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4393/']