根据一个数区分小时,分钟,秒
/// <summary> /// 根据一个数,区分小时,分钟,秒 /// </summary> /// <returns></returns> public string GetTimeString() { string time = ""; try { TimeSpan ts = new TimeSpan(0, 0, recordCount); //recordCount 就是那个数 if (ts.Hours.ToString().Length < 2) { time += "0" + ts.Hours + ":"; } else { time += ts.Hours + ":"; } if (ts.Minutes.ToString().Length < 2) { time += "0" + ts.Minutes + ":"; } else { time += ts.Minutes + ":"; } if (ts.Seconds.ToString().Length < 2) { time += "0" + ts.Seconds; } else { time += ts.Seconds; } } catch(Exception ex) { MedicalLog.InsertSystemLog("VideoRecordItem.cs", "GetTimeString", ex); } return time; }
返回的格式是: 00:00:00
时间: 2024-10-24 13:05:57