自定义方法:根据身份证账号获取出生日期
#region 根据身份证获取出生日期
/// <summary>
/// 根据身份证获取出生日期
/// </summary>
/// <param name="Card"></param>
/// <returns></returns>
private DateTime GetBirthDayByCard(string Card)
{
try
{
if (Card.Trim().Length == 18 || Card.Trim().Length == 15)
{
string data = Card.Trim().Length == 18 ? Card.Trim().Substring(6, 8) : "19" + Card.Trim().Substring(6, 6);
data = data.Substring(0, 4) + "-" + data.Substring(4, 2) + "-" + data.Substring(6, 2);
return DateTime.Parse(data);
}
}
catch (Exception ex)
{
PageHelper.ShowMassage(this.Page, "身份证号输入有误!");
}
return new DateTime();
}
#endregion