C# 秒数转日期_由秒数得到日期几天几小时
///<summary> ///由秒数得到日期几天几小时。。。 ///</summary ///<param name="t">秒数</param> ///<param name="type">0:转换后带秒,1:转换后不带秒</param> ///<returns>几天几小时几分几秒</returns> public static string parseTimeSeconds(int t, int type) { string r = ""; int day, hour, minute, second; if (t >= 86400) //天, { day = Convert.ToInt16(t / 86400); hour = Convert.ToInt16((t % 86400) / 3600); minute = Convert.ToInt16((t % 86400 % 3600) / 60); second = Convert.ToInt16(t % 86400 % 3600 % 60); if (type == 0) r = day + ("天") + hour + ("小时") + minute + ("分") + second + ("秒"); else r = day + ("天") + hour + ("小时") + minute + ("分"); } else if (t >= 3600)//时, { hour = Convert.ToInt16(t / 3600); minute = Convert.ToInt16((t % 3600) / 60); second = Convert.ToInt16(t % 3600 % 60); if (type == 0) r = hour + ("小时") + minute + ("分") + second + ("秒"); else r = hour + ("小时") + minute + ("分"); } else if (t >= 60)//分 { minute = Convert.ToInt16(t / 60); second = Convert.ToInt16(t % 60); r = minute + ("分") + second + ("秒"); } else { second = Convert.ToInt16(t); r = second + ("秒"); } return r; }
好用