Convert Unix Epoch Time to format HH:MM:SS without the date

百般思念 提交于 2019-12-11 09:26:12

问题


I'm using SSRS 2005 and I need to convert time from a serial unix time like 3412.254263 to a duration like 166:12:35 where the second format is HH:MM:SS.

All .NET code should work, but I can't find any function that does not include the date or does not treat the result as a duration.

Any help would be appreciated!


回答1:


Public Shared Function formatSeconds(ByVal seconds As Double) As String
    Dim ts As TimeSpan = TimeSpan.FromSeconds(seconds)
    Return String.Format("{0:00}:{1:00}:{2:00}", Math.Floor(ts.TotalHours), ts.Minutes, ts.Seconds)
End Function

EDIT: I placed it in a function, with VB.NET syntax.



来源:https://stackoverflow.com/questions/2741650/convert-unix-epoch-time-to-format-hhmmss-without-the-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!