Home How do I calculate someone's age in C#?
Reply: 0

How do I calculate someone's age in C#?

user9045 Published in September 21, 2018, 2:58 am

Given a DateTime representing a person's birthday, how do I calculate their age in years?


locked by Yvette Colomb Apr 21 at 17:49

This post has been locked while disputes about its content are being resolved. For more info visit meta.

  • 127
    what all of the answers so far have missed is that it depends where the person was born and where they are right now. – Yaur May 21 '11 at 7:34
  • 37
    @Yaur: Just convert the time of now + birth into GMT/UTC, age is only a relative value, hence timezones are irrelevant. For determining the user's current timezone, you can use GeoLocating. – Stefan Steiger Oct 3 '11 at 10:20
  • Why not consider [Julian Date][1]? [1]: stackoverflow.com/questions/7103064/… – Muhammad Hewedy Oct 5 '13 at 13:32
  • 4
    If we're taking into consideration @Yaur 's suggestion of cross-timezone calculations, should Day Light Saving Time affect the calculation in any manner? – DDM Jul 11 '15 at 3:42
  • No one has considered leap years? or checking the month? – Crash Override Jun 15 '17 at 10:06

64 Answers 64

active oldest votes
1 2 3 next
up vote 1752 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.457304 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO