title: Get proper term of person life using gmtime()
body: <p>I'm trying to calculate exact age of person using difference between now  and the date of birth. I'm getting difference in seconds, which, I suppose is correct value. Then i'd like to convert seconds into <code>struct tm</code>, using <code>gmtime()</code>. But it is giving me a <code>tm_year</code> on 70 bigger than it must be, and <code>tm_mday</code> on 1 bigger than must be. It seems to be clear about <code>tm_mday</code>- the range of it is from 1 to 31, I can just subtract 1 from, whereas <code>tm_year</code> is the years from 1900. OK, so why does <code>gmtime()</code> give me +70 years?</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;ctime&gt;
  using namespace std;
  
  int main() {
  int min,h,d,m,y;
  struct tm bd = {0};
  cout &lt;&lt; &quot;Enter birth date in the format: hh:min/dd.mm.yyyy&quot;&lt;&lt;endl;
  scanf(&quot;%d:%d/%d.%d.%d&quot;,&amp;h,&amp;min,&amp;d,&amp;m,&amp;y);
  bd.tm_year = y-1900;
  bd.tm_mon = m-1;
  bd.tm_mday = d;
  bd.tm_hour = h;
  bd.tm_min = min;
  
  time_t now = time(NULL);
  cout &lt;&lt; &quot;NOW: &quot;&lt;&lt;now&lt;&lt;&quot; BD: &quot;&lt;&lt;mktime(&amp;bd)&lt;&lt;endl;
  time_t seconds = difftime(now,mktime(&amp;bd));//(end,beginning)
  cout &lt;&lt;&quot;seconds elapsed: &quot;&lt;&lt; seconds&lt;&lt;endl;
  struct tm * age;
  age = gmtime (&amp;seconds);
  cout &lt;&lt; &quot;year&quot; &lt;&lt; age-&gt;tm_year &lt;&lt; endl;
  cout &lt;&lt; &quot;mon&quot; &lt;&lt; age-&gt;tm_mon &lt;&lt; endl;
  cout &lt;&lt; &quot;mday&quot; &lt;&lt; age-&gt;tm_mday &lt;&lt; endl;
  cout &lt;&lt; &quot;hour&quot; &lt;&lt; age-&gt;tm_hour &lt;&lt; endl;
  cout &lt;&lt; &quot;min&quot; &lt;&lt; age-&gt;tm_min &lt;&lt; endl;
  cout &lt;&lt; &quot;sec&quot; &lt;&lt; age-&gt;tm_sec &lt;&lt; endl;
  </code></pre>
  <p>}</p>
  <p>output:</p>
  <pre><code>Enter birth date in the format: hh:min/dd.mm.yyyy
  13:28/04.03.2021
  NOW: 1614853702 BD: 1614853680
  seconds elapsed: 22
  year  70
  mon   0
  mday  1
  hour  0
  min   0
  sec   22
  </code></pre>