C# calculate accurate age

前端 未结 14 1783
攒了一身酷
攒了一身酷 2020-12-15 11:01

anyone know how to get the age based on a date(birthdate)

im thinking of something like this

string age = DateTime.Now.GetAccurateAge();
14条回答
  •  执笔经年
    2020-12-15 11:50

    To get the age I would use the datetime of the birthdate and find the difference between that and the current system time. This link shows how to find the difference between two datetimes. Just make the starttime be the user's birthdate and endtime be now (DateTime.Now;)

提交回复
热议问题