display timespan nicely

前端 未结 4 2255
心在旅途
心在旅途 2021-02-19 01:48

Excuse the rough code, I\'m trying to display the duration of videos given the time in seconds. I\'ve had a go below but it\'s not working properly.

I want it to just d

4条回答
  •  梦谈多话
    2021-02-19 02:36

    readonly static Char[] _colon_zero = { ':', '0' };
    // ...
    
    var ts = new TimeSpan(DateTime.Now.Ticks);
    String s = ts.ToString("h\\:mm\\:ss\\.ffff").TrimStart(_colon_zero);
    
    .0321
    6.0159
    19.4833
    8:22.0010
    1:04:2394
    19:54:03.4883

提交回复
热议问题