DateTime获得年龄
2017-01-25 17:05:00 访问(1357) 赞(0) 踩(0)
/// <summary>
/// DateTime获得年龄
/// </summary>
/// <param name="dt"></param>
/// <param name="dtNow"></param>
/// <returns></returns>
public int DateTimeGetAge(DateTime dtBorn, DateTime dtNow)
{
int year = dtNow.Year - dtBorn.Year;
int theResult = 0;
if (dtBorn.AddYears(year) > dtNow)
theResult = year - 1;
else
theResult = year;
return theResult;
}
标签:
DateTime获得年龄 


上一条:
下一条:
相关评论
发表评论