C# + Format TimeSpan

后端 未结 10 671
忘掉有多难
忘掉有多难 2020-12-09 01:44

I am trying to format a TimeSpan element in the format of \"[minutes]:[seconds]\". In this format, 2 minutes and 8 seconds would look like \"02:08\". I have tried a variety

10条回答
  •  -上瘾入骨i
    2020-12-09 02:03

    TimeSpan t = TimeSpan.Parse("13:45:43");
    Console.WriteLine(@"Timespan is {0}", String.Format(@"{0:yy\:MM\:dd\:hh\:mm\:ss}", t));
    

提交回复
热议问题