#region 秒转换小时 SecondToHour /// <summary> /// 秒转换小时 /// </summary> /// <param name="time"></param> /// <returns></returns> public static string SecondToHour(double time) { string str = ""; int hour = 0; int minute = 0; int second = 0; second = Convert.ToInt32(time); if (second > 60) { minute = second / 60; second = second % 60; } if (minute > 60) { hour = minute / 60; minute = minute % 60; } return (hour + "小时" + minute + "分钟" + second + "秒"); } #endregion
比如:一个小时=60分=3600秒
调用:SecondToHour(3600);
显示:
1小时0分钟0秒 |
可以再进行优化,如果分钟和秒为0时,就不显示。
http://blog.csdn.net/lilinoscar/article/details/51968565