62,244
社区成员




protected void Page_Load(object sender, EventArgs e)
{
string str = "20110725";
Response.Write(ConvertDate(str).ToString("yyyy-MM-dd"));
}
public DateTime ConvertDate(string strDate)
{
char[] dates = strDate.ToCharArray();
string strresult = "";
for (int i = 0; i < dates.Length; i++)
{
strresult += dates[i];
if ((i + 1) % 2 == 0 && i != 1 && i != 0 && i != dates.Length - 1)
{
strresult += "-";
}
}
return Convert.ToDateTime(strresult);
}
string dt = "20110725";
st = string.Format("{0}-{1}-{2}", dt.SubString(0, 4), dt.SubString(4, 2), dt.SubString(6));
str.Insert(4, "-").Insert(str.Length - 1, "-")