C# 将秒转换为(小时:分钟:秒:毫秒) 作者:马育民 • 2024-08-27 09:36 • 阅读:10014 # .Net <= 4.0 ``` TimeSpan t = TimeSpan.FromSeconds( secs ); string answer = string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms", t.Hours, t.Minutes, t.Seconds, t.Milliseconds); ``` # .NET > 4.0 ``` TimeSpan time = TimeSpan.FromSeconds(seconds); string str = time .ToString(@"hh\:mm\:ss\:fff"); ``` 参考: https://stackoverflow.org.cn/questions/463642 原文出处:http://www.malaoshi.top/show_1IX8JePU2ViY.html