title: Powershell - Getting a persons age
body: <p>I'm trying to get a person age in Years,Months,Days,Hours,Minutes and Seconds.</p>
  
  <p>This is what I got so far (you can tell I'm a total powershell beginner):</p>
  
  <pre><code>$now = [datetime]::now
  [datetime]$birthday = "12/22/2012 03:22:00"
  $age = [datetime]$now - $birthday
  
  Write-Host "My daughter's age is:" $age.Days "days" ($age.Hours) "hours" ($age.Minutes) "minutes" ($age.Milliseconds) "seconds"
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>My daughter's age is: 59 days 10 hours 27 minutes 76 seconds
  </code></pre>
  
  <p>It's ok, but it would be more awesome have the output more 'human readable':</p>
  
  <pre><code>1 Month 19 Days 10 hours 28 minutes 16 seconds
  </code></pre>
  
  <p>This is actually way more difficult than I initially expected. The code must know how many days has each month in order to split days into months and days. And also consider that this year is leap year!</p>
  
  <p>Maybe PowerShell can help here with some of its magic!</p>
  
  <p>Thank you!</p>