有很多方法
/// <summary>
/// 转为天-时:分:秒
/// </summary>
public static string GetTimeDDHHMMSS(int totalSeconds)
{
int days = (totalSeconds / 3600) / 24;
int hours = (totalSeconds / 3600) - (days * 24);
int minutes = (totalSeconds - (hours * 3600) - (days * 86400)) / 60;
int seconds = totalSeconds - (hours * 3600) - (minutes * 60) - (days * 86400);
if(days > 0)
return string.Format("{0:D2}-{1:D2}:{2:D2}:{3:D2}", days, hours, minutes, seconds);
else if(hours > 0)
return string.Format("{0:D2}:{1:D2}:{2:D2}", hours, minutes, seconds);
else
return string.Format("{0:D2}:{1:D2}", minutes, seconds);
}
/// <summary>
/// 时:分:秒 日/月/年的格式显示当前系统时间
/// </summary>
public static string GetTimeYTD()
{
int hour = System.DateTime.Now.Hour;
int minute = System.DateTime