方法如下:
DateTime.Parse("2008-09-01 12:02:30").ToString("hh:mm:ss");
/// <summary>
/// 返回 年
/// </summary>
/// <param name="sender"></param>
/// <param name="e">时间字符串</param>
public string GetYear(string DateString)
{
if (DateString != "")
{
return DateTime.Parse(DateString).Year.ToString();
}
return "";
}
/// <summary>
/// 返回月份
/// </summary>
/// <param name="sender"></param>
/// <param name="e">时间字符串</param>
public string GetMonth(string DateString)
{
if (DateString != "")
{
return DateTime.Parse(DateString).Month.ToString();
}
return "";
}
/// <summary>
/// 返回 天数
/// </summary>
/// <param name="sender"></param>
/// <param name="e">时间字符串</param>
public string GetDay(string DateString)
{
if (DateString != "")
{
return DateTime.Parse(DateString).Day.ToString();
}
return "";
}